Joel VanderWerf wrote:
> Yukihiro Matsumoto wrote:
>> Hi,
>>
>> In message "Re: [RCR] Thread.abort_on_exception default to true"
>>     on Tue, 21 Jul 2009 06:19:55 +0900, Roger Pack 
>> <rogerpack2005 / gmail.com> writes:
>>
>> |Background:
>> |currently if you have a thread that "dies" without being cleaned up
>>
>> What do you mean by "clean up" here?  If you care about the thread
>> status, you can call join, that reports the exception inside of the
>> thread.
>
> If you don't know when a thread will finish, it's hard to know when to 
> call join. I'm not arguing for the RCR, though. The default makes 
> sense to me--one poorly-rescued thread won't take down the process.
>
> Still, I don't see an easy way for a master thread to wait for worker 
> threads to finish and report their results as soon as they are 
> available. The alternatives:
>
> 1. thread.each {|t| t.join} # blocks on first running thread
>
> 2. polling
>
> 3. queues
>
> Maybe if there were a ThreadGroup#wait or something...
>

There is ThreadsWait#all_waits which can execute a block as each thread 
ends, and there is ThreadsWait#next_wait which returns the next thread 
that terminates.

http://ruby-doc.org/stdlib/libdoc/thwait/rdoc/classes/ThreadsWait.html

-Justin