2010/3/4 Joe Martin <jm202 / yahoo.com>: > I created a pool of threads (say, 500 threads) to process. ¨Βοχεφεςδυ> to the weight of each thread, I want to limit the number of threads that > run concurrently. > > So how would I go about putting a limit on the number of threads that > run at any given time? ¨Β χουμμιλε το ταλεσαω¬ τθςεαδζςον τθ> pool and run them, and as each one completes, it is removed from the > pool and is replaced with a new thread from the pool. > > Could this be done with a "spy" thread, in that it constantly loops to > check how many threads are running at once, and if the number of running > threads falls below the limit of 5, it takes the next thread out of the > pool and runs it? ¨Βοτ συςε θοχουμηο αβουδοιξτθισπςεττω ξε> to multithreading. Why do you create a pool much larger than the load you want to accept? Usually the pool size is used to limit concurrency. Actually that is the main purpose of thread pools. If you have different tasks for which you want to have different limits on concurrency you could also create several pools with different sizes. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/