Use the Monitor class when you want to have a lock object for blocks with mutual exclusion.

require 'monitor'

lock = Monitor.new
lock.synchronize do
  # exclusive access
end
Instance Methods

Enters exclusive section.

Leaves exclusive section.

An alias for
An alias for

Creates a new MonitorMixin::ConditionVariable associated with the Monitor object.

Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits. See example under MonitorMixin.

Attempts to enter exclusive section. Returns false if lock fails.