Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: from pseudofork to threads

by Ctrl-z (Friar)
on Feb 02, 2003 at 15:59 UTC ( [id://232006]=note: print w/replies, xml ) Need Help??


in reply to from pseudofork to threads

hmm, i think ive got my answer here
so for join(), that should be something like
use threads; my @kiddies; foreach(1..10) { print "$$ starting loop $_"; push @kiddies, threads->new(\&thisWasAnElse); print "$$ exiting loop $_"; } sub thisWasAnElse { print "\tchild ", threads->tid() " created ok"; sleep(int(rand(10))); print "\tchild", threads->tid() , " done, outta here"; } foreach @kiddies { $_->join(); }
can i safely detach() inside the first foreach loop?

well the downloads complete, so lets see what happens...

Replies are listed 'Best First'.
Re: Re: from pseudofork to threads
by pg (Canon) on Feb 02, 2003 at 18:18 UTC
    You can detach in the first loop, but as whether it is safe, really depeneds on what the child thread is doing.

    When the main thread exit, all child threads will be shut down at unpredictable point, it might seriously hurt what you are doing (, again really depends what it is doing).

    As far as Perl is concerned, that doesn't matter, although it will warn you that you exit when some threads running.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://232006]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-19 21:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found