Issue #5958 has been updated by Eric Hodel.


As another design restriction, the thread list should ensure that threads started in the ThreadGroup appear at the end of the list and not randomly to ensure all the threads are joined.  Otherwise, joining a ThreadGroup may leave threads running.

Enclosing the ThreadGroup will help as existing threads cannot be added or removed, but threads in the group may still spawn new threads.
----------------------------------------
Feature #5958: ThreadGroup#join
https://bugs.ruby-lang.org/issues/5958

Author: Masaki Matsushita
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: 


=begin
I propose the method ThreadGroup#join.
Calling thread waits all threads in receiving threadgroup.

 thgrp = ThreadGroup.new
 thgrp.add(Thread.new{ sleep 1 })
 thgrp.join #=> #<ThreadGroup:0x007ff257d6d098>

Time limit to run the threads in the threadgroup can be specified.
If the time limit expires, nil will be returned.

 thgrp = ThreadGroup.new
 thgrp.add(Thread.new{})
 thgrp.add(Thread.new{ sleep })
 thgrp.join(0.1) #=> nil

I think it is useful to wait grouped threads together.
=end


-- 
http://bugs.ruby-lang.org/