I'm wondering if it's possible to continue in my same method call after I've killed the thread. Currently I call a sub that spawns a new thread and once the thread has done it's job it gets killed. My issue is that I'm unable to continue in the initial thread call after it has been killed. I hope that makes sense. Here is what I'm doing:
use threads; use threads::shared; use Thread::Queue; # Signal Handler $SIG{'KILL'} = sub { # Tell user we've been terminated printf(" %3d <- Killed\n", threads->tid()); # Detach and terminate threads->detach() if ! threads->is_detached(); threads->exit(); }; StartThread(); sub StartThread { my @threads = threads->list(); # Check to see if there any running threads foreach ( @threads ) { print "Killing thread ... "; $_->kill('KILL'); print "Done\n"; } # Spawn new thread my $worker = threads->create(\&StartTest ); } sub StartTest { for ( 0..10 ) { print "I: $_\n"; } StartThread(); }
I'm trying to create a new thread by calling the StartThread after it prints to 10.

In reply to continue after killing thread? by Anonymous Monk

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.