From: Christopher Dicely Date: 2011-05-08T12:36:48+09:00 Subject: Re: Threading Loops On Sat, May 7, 2011 at 6:56 PM, 7stud -- wrote: > Hi, > > I don't think threading will speed up your execution time in this case. > Threading is an illusion: processing switches rapidly between threads; > threads don't actually execute at the same time. Well, if you are using Ruby 1.8 with its green threads, or Ruby 1.9 and not calling native routines that release the global interpreter lock. If you are using JRuby, threads are concurrent native threads with no GIL, so they do run concurrently, and you should see a speedup on tasks that are CPU-bound and efficiently parallelizable. > === > ...if your machine has more than one processor, Ruby threads won't take > advantage of that fact - because they run in one process, and in a > single native thread, they are constrained to run on one processor at a > time. > > http://rubylearning.com/satishtalim/ruby_threads.html > === This is true in MRI 1.8, which uses "green" threads implemented in the runtime library with a single native thread backing them. Its not true, from what I understan, in older versions of MacRuby, or Ruby 1.9, or the current versions of Rubinius (in all three of these, threads are native threads, but concurrency is limited by a global interpreter lock), current MacRuby or JRuby (threads are native threads with no global lock), and I haven't seen anything about Maglev's threading model. While the Thread API is part of the Ruby language, threading implementations vary between Ruby implementations.