fork download
  1. threads = []
  2. x = 1
  3. (1..5).each do |i|
  4. x += 1
  5. x2 = x
  6. threads << Thread.new {sleep 1; Thread.current[:output] = "#{x2}" }
  7. end
  8. threads.each do |t|
  9. t.join
  10. puts t[:output]
  11. end
  12.  
Success #stdin #stdout 0.01s 6096KB
stdin
Standard input is empty
stdout
2
3
4
5
6