On 9/14/2010 9:59 PM, Terry M. wrote:
This is a rather important issue for me.
This is a rather confusing issue, but I’ll try to give you a basic
MRI 1.8.7: in 1.8.7 green threads are used. This means that the
interpreter is actually managing the context switching, and all
“threads” are running on a single core. This does still mean that one
thread may be waiting on an IO operation, such as reading the disk,
while another thread is running.
MRI 1.9.2: uses native (true) threads. I.E., the different threads MAY
be on different CPU cores. That said, with some exceptions, code is
still not executed in parallel due to the GIL (Global Interpreter
Lock). The basic reason for this is to ease c-extension developers into
truly concurrent threads, which as I understand it is in the starts for
JRuby: True multi-threading. In JRuby, Ruby threads are Java threads,
and have all the same features and caveats.
Having covered that, I strongly suggest you look into tools for
concurrency via multiple processes, such as Drb (already built into the
language). Shared memory threads tend to be dangerous beasts, and really
aren’t needed that often, especially in environments where concurrency
performance is an issue.