require 'thread' $a = nil thread = Thread.new { for i in 1..10000 $a = i end } puts $a nil until $a == 10000 puts $a thread.join