Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: Need help with Perl multi threading

by chromatic (Archbishop)
on Jan 25, 2012 at 23:36 UTC ( #949993=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Need help with Perl multi threading
in thread Need help with Perl multi threading

With regard to:

foreach my $host ( @servers ) { threads->new(\&process, $host )->join(); }

... creating a new thread and then immediately joining it is a waste of time; join waits for the thread to finish.

In this case, detach is probably better. Otherwise, keep an array of all threads and after you've created all of them, then join all of them.


Improve your skills with Modern Perl: the free book.


Comment on Re^5: Need help with Perl multi threading
Select or Download Code
Re^6: Need help with Perl multi threading
by ashok.g (Beadle) on Jan 27, 2012 at 11:55 UTC
    This was completely opposite to the comment posted in this node

    Anyways I got my task completed by using Net::OpenSSH.

    Thanks,
    Ashok

      BrowserUK and I said essentially the same thing. If you write your thread code as you did, you're not getting any advantage of threading. All of your threads will run serially.

        I am able to run the scripts with Net:;OpenSSH module having the statements like threads->create()->join(). may be it is not a good idea but the script execution time drastically changed and my script is also working as I want.....

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2014-07-23 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (144 votes), past polls