"Zentara" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Mon, 20 Jun 2005 21:46:52 -0600, [EMAIL PROTECTED] (Siegfried > Heintze) wrote: > >>What about the memory used by threads? Do I have to join with a thread to >>recover its memory? >> <snip /> > > To destroy a thread, you must make sure you make the thread goes to the > end of it's code block, then join it. > <snip />
Compliment: This is some of the most beautiful code I've seen on p.b.cgi. Question: But I have a question about the code down in the main thread below: > > ############################################### > sub work{ > $|++; > while(1){ > if($shash{'die'} == 1){ goto END }; > > if ( $shash{'go'} == 1 ){ > > foreach my $num (1..100){ > $shash{'data'} = $num; > select(undef,undef,undef, .1); > > if($shash{'go'} == 0){last} > if($shash{'die'} == 1){ goto END }; > } > > $shash{'go'} = 0; #turn off self before returning > }else > { sleep 1 } > } > END: > } > ###############################################3 > What if the thread is sleeping when the code gets right... > > To destroy the thread from main, > $shash{'die'} = 1; ### HERE ### > $thread->join; > Didnt you say: > When you make a thread, you pass it a subroutine to run. The thread WILL > NOT join unless the thread goes to the end of that subroutine. Agian, beautifuly simple code. Thanks, Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>