On Oct 13, 2007, at 07:29 , Francis Cianfrocca wrote:
> On 10/12/07, Jon Handler <jhandler / shopping.com> wrote:
>> I'm pretty new to ruby and this is one of those areas where I can't
>> quite seem to turn my head inside out as the language requires :-)
>>
>> I have a log file that I want to process in parts, with multiple  
>> threads working from the same file, each one getting a line at a  
>> time and doing something with it.
>>
>> I'd like something like
>>
>> 1. Open the file
>> 2. Create 5 threads
>>
>> Each thread should read a line of the file and process it, but no 2
>> threads should get the same line.
>
> Why are you doing this in the first place? Do you have a computer  
> with five processors and five memory buses?

It depends upon the operation being parallelized.  If your file is  
filled with IP addresses to resolve you will use very little CPU.   
I've used resolv.rb and hundreds of threads to rapidly resolve IP  
addresses streamed from an HTTP access log.

--
Poor workers blame their tools. Good workers build better tools. The
best workers get their tools to do the work for them. -- Syndicate Wars