Paul Lutus wrote:
> I tried to think of an explanation apart from the obvious one, but it seems
> I am wrong. I think the fact that they are all sleeping their time away may
> partly explain this outcome, but the threads are clearly running
> concurrently.
> 
> Threads that are not sleeping may not live up to the promise of this
> example. My threads tend not to run concurrently, but your example is an
> excellent refutation.

Threads that are 100% Ruby code will yield and timeslice correctly. 
However they still will never run concurrently, other than timeslicing. 
Threads that make system calls will run sequentially, since system calls 
can't be scheduled by Ruby's thread scheduler. If you have a thread make 
a system call, that call must complete before the thread will yield.

There's some trickery with IO in some cases, but for the general case 
this is how it works. You may try JRuby, which has fully concurrent 
native thread support, but not everything in normal Ruby is 100% 
supported yet...and Kernel#system isn't quite perfect yet.

-- 
Charles Oliver Nutter, JRuby Core Developer
headius / headius.com -- charles.nutter / sun.com
Blogging at headius.blogspot.com