def shutdown(timeout=2)
      threads = nil

      @mutex.lock
      begin
        return false if @state == :shutdown
        @state = :shutdown

        @queue.clear
        threads, @threadpool = @threadpool, []
        @cond.broadcast
      ensure
        @mutex.unlock rescue nil
      end

      join_all(threads)

      nil
    end
def shutdown(timeout=2)
      threads = nil

      @mutex.lock
      begin
        return false if @state == :shutdown
        @state = :shutdown

        @queue.clear
        threads, @threadpool = @threadpool, []
        @cond.broadcast
      ensure
        @mutex.unlock rescue nil
      end

      join_all(threads)

      nil
    end
join all threads in this threadpool, they will be given a maximum of +timeout+
 seconds to exit before they are considered hung and will be ignored (this is an
 issue with threads in general: see
 http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html for more info)

 the default timeout is 2 seconds per thread