in reply to Re^2: cleanly exiting threads
in thread cleanly exiting threads

I don't use Thread::Queue myself, but I had this old sample around that says it's kindof obsolete, I may be wrong. Maybe try this style?
#!/usr/bin/perl #leaks memory- Threads::Queue is for the old Threads <5.7 use strict; use threads; use Thread::Queue; my @threads; my $thread; my $q = Thread::Queue->new(); $q->enqueue(1..100000); 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 ; } }

I'm not really a human, but I play one on earth Remember How Lucky You Are