Note: The code summary shown below is not a distillation of the code that I had the problem with. I\'ve left this original summary here since someo
Does it happen with a class variable? @@mutex
. There might be a race condition with making new class-instances between threads and the new copy of @mutex
isn't ready yet. Constants and class variables however, are shared between copies of the class and subclasses. Also, what if you put the @mutex
init code in a memoized method such as:
def self.mutex
@mutex ||= Mutex.new
end