exilepanda has asked for the wisdom of the Perl Monks concerning the following question:
Not sure I missed some point somewhere. This script ends immediately without doing anything. ( I am on WinXP pro ) This will going fine(as expected) if I use join() instead.use threads; $thr = threads->new(\&sub1); # Spawn the thread $thr->detach; # Now we officially don't care any more sub sub1 { $a = 0; while (1) { $a++; print "\$a is $a\n"; sleep 1; } }
Will somebody tell me :
1. Why the turn out is given in this way?
2. How to create a thread and then leave it alone ? ie, I don't want to be warned for some threads not joined.
I do wish can write the whole thread declaration in a line like this :
threads->create("t_sub1")->detach(); threads->create("t_sub2")->detach();
Thank you very much!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: detach for threads
by Khen1950fx (Canon) on Nov 15, 2011 at 11:09 UTC | |
|
Re: detach for threads
by Anonymous Monk on Nov 15, 2011 at 08:47 UTC | |
by exilepanda (Friar) on Nov 15, 2011 at 09:46 UTC | |
by zentara (Cardinal) on Nov 15, 2011 at 10:44 UTC | |
by Sewi (Friar) on Nov 15, 2011 at 11:00 UTC | |
by Anonymous Monk on Nov 15, 2011 at 11:22 UTC |