znu has asked for the wisdom of the Perl Monks concerning the following question:
And this is the code for the worker:my @running_threads = (); while ($finished eq "false") { @running_threads = threads->list; if (scalar(@running_threads) < $worker_num) { print "launching thread with count:$count\n"; $somedata = getData(); if ($somedata ne "") { threads->new(\&worker, $somedata); } else { $finished = "true"; } } }
sub worker { # do whatever eval((threads->self)->join); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fun with threads
by pg (Canon) on Dec 20, 2002 at 02:33 UTC | |
by znu (Acolyte) on Dec 20, 2002 at 02:39 UTC | |
by submersible_toaster (Chaplain) on Dec 20, 2002 at 06:44 UTC | |
|
Re: Fun with threads
by submersible_toaster (Chaplain) on Dec 20, 2002 at 03:22 UTC | |
by znu (Acolyte) on Dec 20, 2002 at 03:46 UTC | |
by submersible_toaster (Chaplain) on Dec 20, 2002 at 08:29 UTC | |
by znu (Acolyte) on Dec 21, 2002 at 07:20 UTC | |
by submersible_toaster (Chaplain) on Jan 06, 2003 at 03:27 UTC | |
|
Re: Fun with threads
by batkins (Chaplain) on Dec 20, 2002 at 02:35 UTC |