On 5/12/07, Tim Becker <a2800276 / gmail.com> wrote: > I'm trying to build a message queue that can receive messages, blocks > until messages arrive and has the ability to only block for a limited > amount of time. Unfortunately, the build-in Queue doesn't support > timeout behaviour, so I went about implementing a queue myself. I > missed java's Object.wait method, i.e. using a plain object to notify > the blocking thread to resume . Use 'timeout': require 'timeout' require 'thread' q = Queue.new Thread.new do q.push "thing" sleep 10 end begin Timeout::timeout(1) do q.pop q.pop end rescue Timeout::Error puts "timed out!" end -- Avdi