#!/usr/bin/perl # use threads; use Thread::Queue; use warnings; use Fcntl ':flock'; sub process { my $i = shift; my $q = Thread::Queue->new(); $q->enqueue($_) for($i .. $i+9000); $q->enqueue( (undef) x 10 ); for(0 .. 9) { threads->new(\&worker, $q); } $_->join for threads->list; } sub worker { my $queue = shift; while( my $item = $queue->dequeue) { print $item."\n"; } return; } my $i = 0; until($i > 50000) { &process($i); $i+=9000; }
In reply to Re: Slow worker threads
by pome23
in thread Slow worker threads
by pome23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |