in reply to 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.
foreach(@array){ push @threads, threads->create(\&execute_ls, $_); } # when you loop thru @threads to join, join will wait for each thread to finish and becoming joinable foreach (@threads) { $_->join(); } # better would be foreach (@threads) { if ( ( $_ -> is_joinable) { $_->join(); } } alternatively you can detach your threads, instead of joining them, and write your return values to shared variables
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Issue with Threads while collecting command output
by BrowserUk (Patriarch) on Nov 08, 2011 at 14:10 UTC | |
by zentara (Cardinal) on Nov 08, 2011 at 16:42 UTC |