Take this code from the Ruby Cookbook:
module Enumerable
def each_simultaneously
threads = []
each { |e| threads << Thread.new { yield e } }
return threads
end
end
It is used on an array so that you may do this:
[1,2,3].each_simultaneously do |i|
sleep 5
puts i
end
And it works!
But why don't I need to call threads.each {|t| t.join }?
And if I did, would it slow it down?
Thanks,
Ari
-------------------------------------------|
Nietzsche is my copilot