So, Ruby 1.9.1 is now declared stable. Rails is supposed to work with it and slowly gems are being ported to it.
It has native threads and a global interpreter lock (GIL).
Since a GIL is in place, do native threads offer any kind of benefit over green threads in 1.9.1?
The threads in 1.9 are native, but they have been "slowed down" to allow only one thread to run at a time. This is because it would confuse existing code, if the threads really ran in parallel.
Pros:
Cons:
priority()
is different between Solaris, Windows, and Linux. Things like loop {}
run fine in Linux, other threads get a chance to run. However, on Solaris threads that thread hogs the process's time and you'll never exit!I think the big win, is that C based extensions can release the GIL. So, for example, a MySQL adapter can quite cleanly run long running database queries without blocking up all the other Ruby threads.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With