Help for this page

Select Code to Download


  1. or download this
    while (1) {
       sleep 1;
       ...
    }
    
  2. or download this
    while (1) {
       sleep 1;
       my $thread = threads->new(\&work_sub);
    }
    
  3. or download this
    #!/usr/bin/perl -w
    
    ...
       my $thread = threads->new( sub { print "foo"; sleep 1; print "\n" }
    +);
       $thread->detach;
    }
    
  4. or download this
    join() does three things: it waits for a thread to exit, cleans up 
    after it, and returns any data the thread may have produced.
    ...
    In this case, you use the detach() method.  Once a thread is 
    detached, it'll run until it's finished, then Perl will
    clean up after it automatically.