Hope this isn't too long a post -- I was wanting some feedback on the
following code. A couple questions:

- Anyway to improve it? 
- Have I reinvented the wheel (does something like this already exist
somewhere)?

require 'thread'

class SharedQueueThread
  def initialize(id, queue, mutex)
    @id = id
    @queue = queue
    @mutex = mutex
    while queueIsNotEmpty
      item = nil
      @mutex.synchronize { item = @queue.pop }
      execute(item) if item != nil
    end
  end
  
  def queueIsNotEmpty
    result = true
    @mutex.synchronize { result = !@queue.empty? }
    return result
  end
  
  def execute(item)
  end
end

if __FILE__ == $0
  class DoThing < SharedQueueThread
    def execute(item)
      number = item
      endNumber = number + rand(9) + 1
      puts 'id: ' + @id.to_s + ' - starting ' + number.to_s + '-' +
endNumber.to_s
      number.upto(endNumber) do |i| 
        puts i
        sleep rand
      end
      puts 'id: ' + @id.to_s + ' - done ' + number.to_s + '-' +
endNumber.to_s
    end
  end
  
  numbers = [40, 50, 60, 70, 80, 90, 100]
  mutex = Mutex.new
  
  threads = []
  1.upto(3) { |i| threads << Thread.new { DoThing.new(i, numbers, mutex) } }
  threads.each { |t| t.join }
end