in reply to multi-threaded questions

I don't know about smp distributing threads, I guess the kernel will decide? But here are some general comments on threads.

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;} }

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

Replies are listed 'Best First'.
Re^2: multi-threaded questions
by btoovey (Novice) on Dec 08, 2006 at 14:09 UTC
    Thanks for the tip on doing the join - I was wondering why I was leaving threads hanging