class ThreadsWait

def next_wait(nonblock = nil)


is true, and there is no terminated thread, raises +ErrNoFinishedThread+.
If there is no thread to wait, raises +ErrNoWaitingThread+. If +nonblock+

that does.
Waits until any of the specified threads has terminated, and returns the one
def next_wait(nonblock = nil)
  ThreadsWait.fail ErrNoWaitingThread if @threads.empty?
  begin
    @threads.delete(th = @wait_queue.pop(nonblock))
    th
  rescue ThreadError
    ThreadsWait.fail ErrNoFinishedThread
  end
end