From: Masaki Matsushita Date: 2012-02-26T17:32:33+09:00 Subject: [ruby-core:42947] [ruby-trunk - Feature #5958] ThreadGroup#join Issue #5958 has been updated by Masaki Matsushita. Koichi Sasada wrote: > What should happen when at least one thread causes an exception? Under the patch, joining thread also causes the exception if the thread is being joined. Otherwise, nothing will happen on joining thread. It behaves the same as thgrp.list.each(&:join). I think ThreadGroup#join may be more useful if it catches exceptions from all its threads and handles them like the following. thgrp.join do |th| # each thread which causes an exception # handle an exception end ---------------------------------------- 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 #=> # 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/