From: Mario Camou Date: 2009-08-23T02:43:54+09:00 Subject: Re: Process or Thread? --001636ed78432973070471be8744 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Sat, Aug 22, 2009 at 16:47, 7stud -- wrote: > Pito Salas wrote: > 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 =3D 6 minutes > That's true if you=B4re running MRI, since it uses "green" threads (i.e., = you really have a single OS-level thread that gets task-switched by Ruby itself). However, if you run on JRuby, the Ruby Thread support gets mapped onto the Java Thread support, which *does* map to OS-level threads and therefore will take advantage of multiple cores if you have them. In that case you *would* get faster processing. Hope this helps, -Mario. --001636ed78432973070471be8744--