From: Robert Klemme Date: 2013-03-18T01:17:57+09:00 Subject: Re: control the concurrent thread numbers On Sat, Mar 16, 2013 at 4:01 PM, Ken Paul 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/