Create threads in a while loop : Thread.new « Threads « Ruby






Create threads in a while loop


n = 1
while n <= 3
  Thread.new { puts n }
  n += 1
end

 








Related examples in the same category

1.Pass value into a thread
2.Use upto to create 3 threads
3.manipulate variables from the outer scope
4.Access the thread-local data from outside
5.True local variables (not accessible from outside)