-
-
Save maasha/abeaa9b57e9a57fb179d to your computer and use it in GitHub Desktop.
How to check Queue status?
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
#!/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