in reply to Threads: How to kill a thread manually?

Amplifying on what BrowserUk said, you need to set a shared variable that signals the thread to go to the end of it's code block. Threads must reach the end of their code block to return. Generally you want to be able to have the ability to have the thread 'sleep' , 'go', and 'die'. So set up your worker code in a while loop, if 'go' == 0 , then sleep. If 'go' == 1, do something until it finishes or a 'die' flag == 1. So something like this works (full code in Tk-with-worker-threads ):
sub worker_thread{ my $dthread = shift; $|++; while(1){ if($shash{$dthread}{'die'} == 1){ goto END }; if ( $shash{$dthread}{'go'} == 1 ){ eval( system( $shash{$dthread}{'data'} ) ); foreach my $num (1..100){ $shash{$dthread}{'progress'} = $num; print "\t" x $dthread,"$dthread->$num\n"; select(undef,undef,undef, .5); if($shash{$dthread}{'go'} == 0){last} if($shash{$dthread}{'die'} == 1){ goto END }; } $shash{$dthread}{'go'} = 0; #turn off self before returning }else { sleep 1 } } END: }

I'm not really a human, but I play one on earth. flash japh