cheers :0) JamesNC#!/perl/bin/perl use strict; use threads; use Thread::Queue; my @threads; my $thread; my $q = Thread::Queue->new(); $q->enqueue(1..100); print "Items in the queue: ",$q->pending,"\n"; for (1..5) { push @threads, threads->new(\&ttest); print "spawned thread:"; } foreach $thread (@threads){ $thread->join; } sub ttest { while (my $cnt = $q->pending) { my $item = $q->dequeue; print "$cnt\n"; last if $cnt == 0 ; } }
In reply to Re: Thread::Queue and Memory
by JamesNC
in thread Thread::Queue and Memory
by petesmiley
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |