Re: How to check if a thread is alive?
[email protected] ("EastInspection USA")
| Newsgroups | perl.ithreads |
|---|---|
| Message-ID | <[email protected]> |
Hi Liz,
The main thread spawned many other threads (worker thread). If I join(0ed
any of them, it will cause the main to wait for the worker thread to exit.
It seems to me it is a bug in ithread. If a thread dies, then
ithread->list() should not list it as an alive thread.
perl ithread tutorial & ithread doc clearly state that:
http://www.perldoc.com/perl5.8.0/pod/perlthrtut.html
threads->list returns a list of thread objects, one for each thread that's
currently running and not detached. Handy for a number of things, including
cleaning up at the end of your program:
# Loop through all the threads
foreach $thr (threads->list) {
# Don't join the main thread or ourselves
if ($thr->tid && !threads::equal($thr, threads->self)) {
$thr->join;
}
}
J.
"Elizabeth Mattijsen" <[email protected]> wrote in message
news:p05111b02bbdfa2fb9571@[192.168.56.3]...
> At 16:20 -0500 11/17/03, EastInspection USA wrote:
> >Hi there,
> >
> >In my program, one thread runs into a "die" statement, but when I use
> >threads->list to get a list of thread ids, the "dead" thread is still
there.
> >How come?
> >The thread is not a detached thread.
>
> Have you join()ed the thread?
>
>
> Liz