J
Jaeyong Lee
Hi all,
I learning ruby thread and faced to thread problem.
Here's my test code that sum 1 to 1000.
--
threads = []
sum = 0
1.upto(1000) { |external|
threads << Thread.new(external) { |local|
sleep(rand(0.01))
sum = sum + local
}
}
threads.each() { |thread| thread.join() }
puts sum
I learning ruby thread and faced to thread problem.
Here's my test code that sum 1 to 1000.
--
threads = []
sum = 0
1.upto(1000) { |external|
threads << Thread.new(external) { |local|
sleep(rand(0.01))
sum = sum + local
}
}
threads.each() { |thread| thread.join() }
puts sum