Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Thread exit errors

by JFarr (Sexton)
on Nov 17, 2005 at 22:52 UTC ( #509626=note: print w/replies, xml ) Need Help??


in reply to Re: Thread exit errors
in thread Thread exit errors

Thanks Dave. I'm still very noobish to Perl, so I have a question on your response. the $_->join for threads->list, what does this do. The problem we are having, is that are services have a delay in their response time, being that our farthest host is between 200-400 miles from our distribution. Is this command going to keep the threads alive until a response if found? The reason for the multi threads is that the main thread, launches a method that is launching other threads to search for all of the servies on each host. So,
foreach $host(@syshosts) { @sysThread = threads->new( \&findHostNodes, $host ); } sub findHostNodes { my $host = @_; #print some stuff about the node #now find the services on the host foreach $service (@r21services) { @serviceThread = threads->new(\@shutdonwServices, $service); } } sub shutdownServices { shut down the windows services we are looking for }
From you response, in your opinion, what is the better method? Thanks, Jeff

Replies are listed 'Best First'.
Re^3: Thread exit errors
by dave_the_m (Monsignor) on Nov 17, 2005 at 23:06 UTC
    $_->join for threads->list, what does this do.

    It simply waits for, and then joins, any remaining threads.

    Your problem is simply to ensure that the main process doesn't exit until all threads have been joined. My example is just a simple way to ensure that all remaining threads have been joined.

    Please bear in mind that threads in perl are extremely expensive to create and consume a lot of memory, so I suspect that creating new threads in findHostNodes is a bad idea.

    Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2023-05-31 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?