From: "Jesús Gabriel y Galán" Date: 2010-08-12T18:37:02+09:00 Subject: Re: Multithreading problem On Thu, Aug 12, 2010 at 10:49 AM, Brian Candler wrote: > Jesús Gabriel y Galán wrote: >> 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. > > 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