Hello,
I am having a strange concurrency issue with Thread::Queue. Specifically, in some code that uses threads, the program runs for a time, but eventually all threads are put to sleep. The goal of my program is to read lines from text file A, have each thread perform an operation on a line using another text file B, and then write each result to another text file C. Here is a description of the threads:
use threads; use threads::shared; use Thread::Queue; ... my $thr = threads->create( sub { my $threadId = $i; open my $REFERENCE_FILE, '<', "$refFileName" or die "Can't open $refFileName: $!"; while ( defined( my $item = $inQ->dequeue() ) ) { # get info from the current item my $lot = $item->{ 'lot' }; my $batch = $item->{ 'batch' }; my $part = $item->{ 'part' }; ... # perform an operation on the item ... my %result = ( 'lot' => $lot, 'batch' => $batch, 'part' => $part, 'thread' => $threadId, 'extensions' => \@bestSeedExtensions, 'num_mm' => $bestSeedOverallMismatches, 'beadid' => $beadID, 'read' => $readSequence, ); $outQ->enqueue( \%result ); # <------ I AM BROKEN :( } } );# end sub
Using print statements, I've traced the problem to the outQ->enqueue() statement. The strange part is that everything runs fine for millions of lines and then suddenly all progress stops. Can anyone tell me why this might be happening? I have tried both perl v5.8.5 and v5.10.1.
In reply to Tread::Queue enqueue blocks all of my threads by sivert
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |