On 7 Mar 2007 06:44:56 -0800,
wrote:
>who can help me, to kill the threads in this script.
>I create lot of thread with a tar. If the tar canceled with errors, i
>have to kill the rest of
>the threads with tar. I dont now what is the best way. I tested with
>kill Hup, but doesn't work.
In order for a Perl thread to be killed individually, you need
to make it go to the end of it's code block, or do a return.
So, you need a shared variable in the thread
code, to tell it to return.
Like:
my $die:shared;
$die =0;
#in thread code check for it:
if($die){return}
If you don't detach, you still need to return from the thread
block, before a join can happen.
Joining is preferred over detaching, because you can reuse
the thread, or it's space, and that will avoid gaining memory as
you constantly spawn threads.
In c, threads work alot cleaner, but in Perl, you need to watch
for memory accumulating, and that means reusing threads.
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html