in reply to Help needed with regard to arrays
Instead of creating a new thread, create 10 threads which take their work from a central queue:
my $threadcount = 10; my $jobs = Thread::Queue->new(@xyz); # I use undef as marker when to stop working $jobs->enqueue(undef) for 1..$threadcount; my @workers = map { threads->create( \&work ) } 1..$threadcount; sub work { while (defined (my $item = $jobs->dequeue)) { print "Processing $item\n"; }; };
But maybe I'm misunderstanding the problem you're trying to solve.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Help needed with regard to arrays
by theknightsofni (Novice) on Nov 20, 2008 at 19:17 UTC | |
by Corion (Patriarch) on Nov 20, 2008 at 19:29 UTC | |
by theknightsofni (Novice) on Nov 20, 2008 at 19:48 UTC | |
by Corion (Patriarch) on Nov 20, 2008 at 20:18 UTC | |
by theknightsofni (Novice) on Nov 20, 2008 at 20:36 UTC | |
|