Advantages of non-competitive Ruby Threads in Ruby 1.9?

I read about Ruby 1.9 Thread, and I see that all ruby ​​threads go through Global Interpreter Lock (GIL for friends) and that concurrency does not really exist.

I passed the test (without any signals or wait), and the performance using streams not only does not improve, but it actually takes longer than doing it in series

My main question is what for these threads if they are not parallel? Is there any hope that they will be simultaneously in the future?

+4
source share
2 answers

Many other Ruby interpreters (JRuby, Rubinius) do not actually have a GIL. In addition, MRI 2.0 will also do away with GIL.

In addition, in many cases (for example, while waiting for I / O), the interpreter switches to another thread. Thus, although this is not technically multithreading (in the case of MRI / REE as of 1.9), it does have some advantages.

+3
source

Parallelism does not exist, but Ruby threads do not prevent the execution of Ruby code at the same time. Even on a single-core machine, parallel code can be executed. I think you just combined the terms "parallel" and parallel ".

For more information, see Jesse Storymer, Ruby Threads.

0
source

All Articles