为什么以下
require "bio"
threads = (1..2).map do
Thread.new do
seqs = ["gattaca"] * 5
alignment = Bio::Alignment.new(seqs)
end
end
threads.each {|th| th.join} ; nil
发出此错误消息?
NameError: uninitialized constant Bio::Alignment
from (irb):6
from (irb):10:in `join'
from (irb):10
from (irb):10:in `each'
from (irb):10
答案 0 :(得分:1)
bioruby库(或至少某些版本)使用自动加载。 Autoload不是线程安全的(至少在ruby 1.8中),所以如果两个线程同时访问Bio :: Alignment,你可能会有错误。