Wraps a block in Thread.critical, restoring the original value upon exit
from the critical section.
[Source]
29: def Thread.exclusive
30: _old = Thread.critical
31: begin
32: Thread.critical = true
33: return yield
34: ensure
35: Thread.critical = _old
36: end
37: end