Created
February 16, 2013 01:24
-
-
Save elskwid/4964994 to your computer and use it in GitHub Desktop.
Small example of Queue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' | |
q = Queue.new | |
(0..1000).each{ |i| q << i } | |
puts q.length | |
Thread.new do | |
sleep 1 | |
puts "FIRST #{q.pop}" | |
end | |
Thread.new do | |
loop do | |
sleep 1 | |
puts "SECOND #{q.pop}" | |
end | |
end | |
sleep 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment