is there a clean way to catch the error and allow the program to continue? ... but it seems as if the parent throws a "thread failed to start" error and hangs

Cannot reproduce. I get the error message, but not the hang?

#! perl -slw use strict; use threads; sub condemned { my $tid = threads->tid; my $deathtime = time() + shift; while( sleep 1 ) { printf "$tid : %s\n", scalar localtime; die "T'is a far, far better thing I do now...." if time() > $deathtime; } } sub survivor { my $tid = threads->tid; for ( 1.. 5 ){ sleep 1; printf "$tid : %s\n", scalar localtime; } } my @threads = threads->create( \&condemned, 3 ); push @threads, map threads->create( \&survivor ), 1 .. 3; $_->join for @threads; __END__ c:\test>junk 10 1 : Fri Dec 5 02:04:19 2008 2 : Fri Dec 5 02:04:19 2008 3 : Fri Dec 5 02:04:19 2008 4 : Fri Dec 5 02:04:19 2008 1 : Fri Dec 5 02:04:20 2008 3 : Fri Dec 5 02:04:20 2008 2 : Fri Dec 5 02:04:20 2008 4 : Fri Dec 5 02:04:20 2008 1 : Fri Dec 5 02:04:21 2008 2 : Fri Dec 5 02:04:21 2008 3 : Fri Dec 5 02:04:21 2008 4 : Fri Dec 5 02:04:21 2008 1 : Fri Dec 5 02:04:22 2008 Thread 1 terminated abnormally: T'is a far, far better thing I do now. +... at c:\test\junk.pl line 10. 4 : Fri Dec 5 02:04:22 2008 3 : Fri Dec 5 02:04:22 2008 2 : Fri Dec 5 02:04:22 2008 4 : Fri Dec 5 02:04:23 2008 2 : Fri Dec 5 02:04:23 2008 3 : Fri Dec 5 02:04:23 2008
hangs in the while loop waiting for the "completed" counters to finish up.

If you posted the code, we might stand a chance of understanding what that means?


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: catching threads that die by BrowserUk
in thread catching threads that die by fert

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.