small medium large xlarge

Back to: All Forums  The dRuby Book
28 Mar 2012, 07:30
Makoto Inoue (9 posts)

In page 86~ 87, there is an explanation about Thread.exclusive and Thread.critical, but the explanation is not correct any more.

the original says ### Thread has critical and critical= class methods to control the state of whether you can switch threading. Setting Thread.critical = true prohibits thread switching. While in this state, execution in the running thread can’t move into another thread. To stop this, you have to set Thread.critical = false. You can check whether thread switching is allowed via Thread.critical. To turn on and off thread switching via Thread.critical, it’s common practice to record the previous value before doing Thread.critical = true and then put it back once the critical sectionis processed. Thread.exclusive does exactly that. In fact, the only exclusive locking mechanism in Ruby is Thread.critical. All other locking libraries we are going to learn next, such as Mutex and Queue, are built on top of Thread.critical. ###

Thread.critical is removed at ruby 1.9, so it’s no longer correct.

We are working on new explanation, and will post once new one comes up


  You must be logged in to comment