threads = [] x = 1 (1..5).each do |i| x += 1 threads << Thread.new {sleep 1; Thread.current[:output] = "#{x}" } end threads.each do |t| t.join puts t[:output] end
Standard input is empty
6 6 6 6 6
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!