global
def instantiate_all
def instantiate_all @enter = [] @leave = [] 1.upto(9) {|i| Thread.new { begin Thread.current[:i] = i __sleep instance rescue RuntimeError => mes puts mes end } } puts "Before there were #{num_of_instances(self)}" sleep 3 puts "Now there is #{num_of_instances(self)}" puts "#{@enter.join '; '} was the order of threads entering the waiting loop" puts "#{@leave.join '; '} was the order of threads leaving the waiting loop" end