fert has asked for the wisdom of the Perl Monks concerning the following question:
I haven't played around to much with Threads in perl so far, so I'm trying to determine a way to catch errors that a particular thread throws without hanging the main script.
Note - I am using perl 5.8.8 and using the "threads" package, with "threads::shared" for thread communication.
If I spawn a thread like so:
threads->new ( \&myThreadFunction, $param );
and that thread dies during execution, is there a clean way to catch the error and allow the program to continue? I am assuming the other threads that might have been spawned will continue until completion, but it seems as if the parent throws a "thread failed to start" error and hangs in the while loop waiting for the "completed" counters to finish up.
Thanks for the help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: catching threads that die
by BrowserUk (Patriarch) on Dec 05, 2008 at 02:06 UTC |