In article <[EMAIL PROTECTED]>, Zentara wrote:

> On Sun, 12 Oct 2003 08:24:52 +0200, [EMAIL PROTECTED] (Igor
> Ryaboy) wrote:
[...]
> Bear in mind I'm not a "threading expert", just a hacker with ideas. :-)
> Here is a snippet to try. I used a global for $param instead of passing
> it, but you may be able to pass the $param.  Also maybe you should check
> out the module Thread::Pool, which manages threads and tasks.
> 
> #!/usr/bin/perl
> use threads;
> my @kiddies;
> my $param =10;
> 
> while ($param > 0){
>   print "$$ starting loop $_";
>   push @kiddies, threads->new(\&sub1);
>   print "$$ exiting loop $_\n";
>   $param--;
>  }
> 
> sub sub1{
>  print "\tchild ", threads->tid(), " created ok using param  $param\n";
>  sleep(int(rand(10)));
>  print "\tchild", threads->tid() , " done, outta here\n";
> }
> 
> foreach (@kiddies){ $_->join(); }
> __END__

What does the last line do. I looked at man threads:
$thread->join
           This will wait for the corresponding thread to join. When the
           thread finishes, join() will return the return values of
           the entry point function."

Printing these out (i.e.):
foreach (@kiddies){
    $_->join();
    print "$_ joined.\n";
}

gives me: 
threads=SCALAR(0x81de948) joined.
threads=SCALAR(0x81e180c) joined.
etc.

But what does that mean in slightly plainer English?

-K

-- 
Kevin Pfeiffer
International University Bremen



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to