unixmonster has asked for the wisdom of the Perl Monks concerning the following question:

Hey All, I am taking two processes in Two threads in Perl Code suppose $thread1 = threads->create(sub xx { -----}); $thread2 = threads->create(sub cmd {$res=qq(----); return($res); }); Now I need to Exit $thread1 with (0) status. And want $thread2 to keep running. Is it possible to achive this scenario. Any help is appriciated. Thanks
  • Comment on In a multithreading Perl Code How to Exit one thread while outher thread keeps running ?

Replies are listed 'Best First'.
Re: In a multithreading Perl Code How to Exit one thread while outher thread keeps running ?
by Corion (Patriarch) on Jul 06, 2009 at 12:18 UTC

    Just return from the code in $thread1.

      My condition is I need my code to give Exit (0) status when condition of First thread got satisfied. But at the same time I need my second thread to keep executing. Since This exit status I am going to use in one Scheduling Tool to make my Job Success.

        So you mean you want to keep part of your program running yet signal success to the calling program? That's not possible with threads. You will need to daemonize your program so it runs in the background.

        You should enclose your code in <code></code> tags, so we could try to understand better what are you trying to do...
        []s, HTH, Massa (κς,πμ,πλ)