require 'thread' m = Mutex.new r = 0 max = 1000 (1..max).map{ Thread.new{ i=0 while i