in reply to Why do my threads sometimes die silenty?
Seems to me a thread can exit in one of three ways.
By throwing an exception.
$ perl -Mthreads -e'my $t = async { die "Foo" }; $t->join; say "done"' Thread 1 terminated abnormally: Foo at -e line 1. done
This isn't silent.
By returning.
$ perl -Mthreads -E'my $t = async { "code" }; $t->join; say "done"' done
You can detect this as follows:
$ perl -Mthreads -E'sub t { "code" } my $t = async { t(); warn("return +ed"); }; $t->join; say "done"' returned at -e line 1. done
By calling threads->exit
$ perl -Mthreads -E'sub t { "code" } my $t = async { threads->exit(); +}; $t->join; say "done"' done
You can detect this as follows:
$ perl -Mthreads -E'my $o = \&threads::exit; *threads::exit = sub { wa +rn "exit"; $o->(@_) }; my $t = async { threads->exit(); }; $t->join; +say "done"' exit at -e line 1. done
Another possibility is that your thread isn't responding because it's blocked, not because it exited. What makes you think it died?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Why do my threads sometimes die silenty?
by BrowserUk (Patriarch) on Sep 21, 2011 at 20:18 UTC | |
by ikegami (Patriarch) on Sep 21, 2011 at 21:09 UTC | |
by BrowserUk (Patriarch) on Sep 21, 2011 at 21:18 UTC | |
by ikegami (Patriarch) on Sep 21, 2011 at 22:09 UTC | |
by BrowserUk (Patriarch) on Sep 21, 2011 at 22:17 UTC |