Pass value into a thread : Thread.new « Threads « Ruby
- Ruby
- Threads
- Thread.new
Pass value into a thread
n = 1
while n <= 3
# Get a private copy of the current value of n in x
Thread.new(n) {|x| puts x }
n += 1
end
Related examples in the same category