From: 7stud -- Date: 2009-08-22T23:47:23+09:00 Subject: Re: Process or Thread? Pito Salas wrote: > I have a parent application (which I think of as a test harness) that > wants to invoke a fairly intensive image processing application against > a directory full of image files. Each image is processed independently. > It doesn't sound like your situation will result in improved performance with threads. Things don't actually get done at the same time with threads--that's an illusion. What happens is that there is very fast switching between different tasks. However, if your tasks do not have dead time during the processing, then using threads won't improve performance. For instance, suppose you have two tasks that each take 3 minutes to complete. The processing might happen in this order with threads: task1: 1 minute task2: 1 minute task1: 1 minute task2: 1 minute task1: 1 minute task2: 1 minute -------------- total = 6 minutes But if you just ran each task sequentially without using threads, the total time would also be 6 minutes. Using threads will only speed up processing time if your tasks have idle time when they are doing nothing. During that down time, if you switch to another task in another thread, then total processing time will be lower. -- Posted via http://www.ruby-forum.com/.