On Sat, Mar 16, 2013 at 4:01 PM, Ken Paul <[email protected]> wrote: > Adam Prescott wrote in post #1101931: >> >> As Joel said, what's the problem you're really trying to solve? > > The real problem is that there are plenty of files on disks and a long > list of words stored in an array. I'd count the total appearing times > for every words among these files. > > I need to run this task with a multiple threads program. Each thread > would take one word from the array by shifting a word to ensure other > thread will not do the same task at the same time, then do the counting. > However, the total numbers of thread should be controlled at a number > less than 10.
That's a *very* inefficient way to partition the work because you will be reading each file over and over again - and file IO is slow. Rather you would read each file only once and count all words and finally combine counts. Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- [email protected] | https://groups.google.com/d/forum/ruby-talk-google?hl=en --- You received this message because you are subscribed to the Google Groups "ruby-talk-google" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
