From: David Masover Date: 2010-09-15T14:01:47+09:00 Subject: Re: Ruby Multi-threading? On Tuesday, September 14, 2010 11:07:10 pm Chuck Remes wrote: > On Sep 14, 2010, at 10:59 PM, Terry Michaels wrote: > > I read a Ruby e-book recently that indicated that although Ruby has > > Multi-threading capabilities, it is a fake multi-threading. I.e., the > > interpreter simply switches between the executing threads, rather than > > running them concurrently. > > > > Then recently I came across an online Ruby tutorial that specifically > > said that Ruby threads could be executed in parallel on a multi-core > > machine. So I'm a little confused. > > > > Does Ruby have real multi-threading, or is it just context switching? > > This is a rather important issue for me. > > Just about any book on this topic will have outdated information. Here's > the breakdown. Nice summary, mostly accurate. I'd just like to add that, interestingly... JRuby doesn't have great process management. It has OK process management, but it seems limited by the JVM. This may be better now, and I may be entirely wrong, but I wouldn't trust fork here. With MRI, on the other hand, fork has always worked. The only sticky part is that no mainstream versions of MRI play nice with COW, which means the entire process memory _will_ be copied as soon as GC runs. The usual answer seems to be: Use JRuby if you really want threads, but most Ruby people care more about scaling to multiple machines more than multicore on the same machine, at which point it becomes really easy to just spin up a bunch of MRIs.