rails中的’deadlock detected’错误

我的代码中检测到死锁错误,并且不明白为什么。

有人可以告诉我,我做错了什么?

#!/usr/bin/ruby ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development' require File.expand_path(File.dirname(__FILE__) + "/config/environment") mutex = Mutex.new threads = [] 1.upto(10) do |i| threads << Thread.new(i) do |id| mutex.synchronize do # here I want to take 1 record from "class Product < ActiveRecord::Base" Product.first end # and to do here some stuff with it # ... # but all I get is # ./sandbox.rb:15:in `join': deadlock detected (fatal) end end threads.each { |thread| thread.join } 

我使用rails 3和ruby 1.9.2