u forgot to add it to ur thread list array "threads[]" after u created a
thread.
so the array "threads[]" left empty and u joined nothing in the end
then these threads were terminated because the main thread was terminated
and u got nothing in that file
But you still need the outer iteration. If I'm already iterating with #each, I change it to map to do both things at the same time
Of course. But for a newcomer to ruby (who is still using 'for' instead
of 'each'), it may be easier to take one step at a time along the road
to enlightenment.
Step 1:
threads = []
for page in str
threads << Thread.new do
...
end
end
Step 2:
threads = []
str.each do |page|
threads << Thread.new do
...
end
end
Step 3:
threads = str.map do |page|
Thread.new do
...
end
end
But you still need the outer iteration. If I'm already iterating with #each, I change it to map to do both things at the same time
Of course. But for a newcomer to ruby (who is still using 'for' instead
of 'each'), it may be easier to take one step at a time along the road
to enlightenment.
Yes, you are right.
···
On Thu, Aug 12, 2010 at 10:49 AM, Brian Candler <b.candler@pobox.com> wrote:
Step 1:
threads = []
for page in str
threads << Thread.new do
...
end
end
Step 2:
threads = []
str.each do |page|
threads << Thread.new do
...
end
end
Step 3:
threads = str.map do |page|
Thread.new do
...
end
end