Skip to content

Instantly share code, notes, and snippets.

@maasha
Last active August 29, 2015 14:07
Show Gist options
  • Save maasha/abeaa9b57e9a57fb179d to your computer and use it in GitHub Desktop.
Save maasha/abeaa9b57e9a57fb179d to your computer and use it in GitHub Desktop.
How to check Queue status?
#!/usr/bin/env ruby
q1 = Queue.new
q2 = Queue.new
t1 = Thread.new do
q2 << (q1.pop + " World")
end
t2 = Thread.new do
sleep 1
q1 << "Hello"
end
while ! q2.empty?
p q2.pop # <<< THIS NEVER HAPPENS
end
p q2.pop
t1.join
t2.join
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment