Created
January 3, 2017 13:25
-
-
Save tamtam180/817c00106bc30972a179b2687cf43b03 to your computer and use it in GitHub Desktop.
why..?
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
# irb | |
2.3.1 :001 > q = Queue.new | |
=> #<Thread::Queue:0x00000002150908> | |
2.3.1 :002 > q.push(:a) | |
=> #<Thread::Queue:0x00000002150908> | |
2.3.1 :003 > q.push(:b) | |
=> #<Thread::Queue:0x00000002150908> | |
2.3.1 :004 > q.pop | |
=> :a | |
2.3.1 :005 > q.pop | |
=> :b | |
2.3.1 :006 > q.pop | |
fatal: No live threads left. Deadlock? | |
from (irb):6:in `pop' | |
from (irb):6 | |
from /usr/local/rvm/rubies/ruby-2.3.1/bin/irb:11:in `<main>' |
q.popでblockしちゃうと他にpushできるスレッドが無いから、そのまま停止してしまうからか。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Personally I think q.pop(false) is blocked when queue is empty.
ruby version: ruby 2.3.1p112