Get the value returned from a thread : Ruby Threads « Threads « Ruby






Get the value returned from a thread


max = 10000
thr = Thread.new do
  sum = 0
  1.upto(max) { |i| sum += i }
  sum
end

puts thr.value

 








Related examples in the same category

1.Basic Ruby Threads in Action
2.Run this block in a new thread
3.Sleep a thread