in reply to multi-threaded questions
When joining, the thread must return from it's code block, either by reaching the end of the block, or with an explicit return.
# bad, you are only joining 1 # $thr->join; # $thr1->join; #better foreach my $thread ( threads->list ) { + $thread->join; + } # or you could stuuff the threads into hashes # like my %thrs; for(1..30){ $thrs{$_}{'thread'} = threads->new(\&thread_sub); } #then join them by looping thru the hash keys
You are probably going to need to use shared variables to control interaction between the threads, but I'm not very familiar with enqueue
sub thread_sub { while ($test == 0) { if (certain test is true) { $test = 1; #maybe test should be shared return; } } # Now here is where I am getting really god damned lost {my $action = $queue->enqueue;} }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: multi-threaded questions
by btoovey (Novice) on Dec 08, 2006 at 14:09 UTC |