提到,如果你没有巨型解释器锁,你会增加竞争条件的风险。这篇博文给出了以下例子:
# As noted in the blog post, this'll work correctly in MRI Ruby (1.8 or 1.9)
# but may or may not work correctly in Rubinius 2.0 or JRuby
@array, threads = [], []
4.times do
threads << Thread.new { (1..100_000).each {|n| @array << n} }
end
th