Type:
Class

This class provides a way to synchronize communication between threads.

Example:

require 'thread'

queue = Queue.new

producer = Thread.new do
  5.times do |i|
    sleep rand(i) # simulate expense
    queue << i
    puts "#{i} produced"
  end
end

consumer = Thread.new do
  5.times do |i|
    value = queue.pop
    sleep rand(i/2) # simulate expense
    puts "consumed #{value}"
  end
end

consumer.join
push

push(obj) Instance Public methods Pushes obj to the queue.

2015-04-29 21:19:52
<<

<<(obj) Instance Public methods Alias of push

2015-04-29 20:44:01