instance method
Thread::Mutex#synchronize
[X] () { () -> X } -> X
mutex.synchronize { ... } → result of the block
thread_sync.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.0.0/thread_sync.rb, line 127
def synchronize
raise ThreadError, "must be called with a block" unless defined?(yield)
Primitive.rb_mut_synchronize
end
Obtains a lock, runs the block, and releases the lock when the block completes. See the example under Thread::Mutex.