我有這個簡單的Ruby代碼:紅寶石線程死鎖致命錯誤
require 'rubygems'
require 'Thread'
queue = Queue.new
t = Thread.new do
loop do
user = queue.pop
puts "Unqueued #{user.nickname}, running all scripts..."
#do stuff
user.run_all
puts "Finished running all script for #{user.nickname}, sleeping for 2"
sleep 2
queue << user
end
end
t.join
當我嘗試運行它,它給了我這個錯誤:
deadlock 0x10ec549f0: sleep:- - ./Machine.rb:9
deadlock 0x10ea46348: sleep:J(0x10ec549f0) (main) - ./Machine.rb:23
fatal: Thread(0x10ea46348): deadlock
from ./Machine.rb:23:in `join'
from ./Machine.rb:23
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):1
我在做什麼錯? 感謝
所以它會在下週被刪除?爲什麼?我做錯了什麼?幫我 – 0xSina 2012-02-01 20:06:30