in reply to how to estimate thread state
If all you are going to do when a thread is not yet joinable, is sleep and loop until it is, then you might as well just call join() and let it block until it is.
With your loop as coded, it means that you may join early finishing threads a little quicker than you would without the loop, but as the loop doesn't terminate (or do anything else), until all the threads are joined, there is really very little benefit to that loop over just calling $_->join for threads->list;. The end result is exactly the same.
The only times it makes sense to only call join if the thread has already finished, is if you are waiting to do something with the threads returned value, or want to start a new thread to replace the old one.
|
|---|