From: Phlip Date: 2008-07-29T12:24:48+09:00 Subject: Re: Running methods in parallel > You can always use threads: Threads are often a patch over bad architecture. You can also try this: foobars = (0..5).map{ Foobar.new("somestuff") } loop do foobars.each{|foobar| foobar.run_one_slice } end Whatever foobar does, it must use some loop statement. If you put the loop on the outside, you will have a better architecture. Each call to run_one_slice performs one foobar activity. Foobar must store its state as instance variables, between each call to .run_one_slice. That forces Foobar to be more object-oriented, and more event-driven. If you start with a good architecture, and measure it, you will know if its performance is adequate, or if it needs more help. Only then you add threads. And threads work best with event-driven architectures, so adding the thread last is always better than adding it first. Premature optimization is the root of all evil. -- Phlip