in reply to Re: Issue with Threads while collecting command output
in thread Issue with Threads while collecting command output

The only thing I can see wrong, which may cause hanging, is the way you wait for the thread joins to occur.

Since he is waiting for all threads to finish, the order in which they are joined is irrelevant.

And using your method, if the first thread (or the first two or the first three) are not yet ready when he tests to see if they are joinable, they will never be joined because your for loop will end and you never go back to re-try them.

You would have to code that as:

while( @threads ) { foreach (@threads) { if ( ( $_ -> is_joinable) { $_->join(); } } }

But that would be pointless.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^3: Issue with Threads while collecting command output
by zentara (Cardinal) on Nov 08, 2011 at 16:42 UTC
    Just checking to see if you had your coffee today...;-), I'm glad you caught that for-while loop oversight.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh