Why do you want to do this? I ask because I think you may be confused about what join() does.
The purpose of join is to allow the thread that creates the child thread to retrieve any return value(s) from the child thread. There is no way to do that from the executing thread as, by definition, the executing thread hasn't yet returned, so there is nothing to retrieve. If you do try it, it will simply block forever. It should probably report an error if the attempt is made, but that doesn't happen.
I think that what you are trying to do is arrange that the threads "go away" automatically when they are finished. To do this, use the detach() method. You can do this either in the main program using the handle returned from the threads creation, or you can do it within the sub by obtaining a handle to the executing thread using the threads->self() method.
sub subname{ # Let the system know that noone is interested # in the return value from the thread threads->self->detach(); # Do stuff # when the stuff is done return; # Commit suicide in an unmarked grave! }
In reply to Re: Threads in perl
by BrowserUk
in thread Threads in perl
by cicbaba
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |