Name
Monitor — Exclusive monitor section class
Synopsis
This class represents exclusive sections between threads.
Required Library
require ‘monitor’
Included Module
MonitorMixin
Class Method
Monitor::new
Creates a
Monitor
object
Instance Methods
m
.enter
Enters exclusive section.
m
.exit
Leaves exclusive section.
m
.owner
Returns the thread that owns the monitor.
m
.synchronize{
...
}
Enters exclusive section and executes the block. Leaves the exclusive section automatically when the block exits.
m
.try_enter
Attempts to enter exclusive section. Returns
false
if lock fails.
Get Ruby in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.