Mutex implements a simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads.
Example:
semaphore = Mutex.new a = Thread.new { semaphore.synchronize { # access shared resource } } b = Thread.new { semaphore.synchronize { # access shared resource } }
Register or
log in
to add new notes.
stevecj -
December 9, 2014
0 thanks
See also ConditionVariable
If you need to and processing with respect to a particular resource between 2 or more threads in more complicated ways, it is likely that ConditionVariable is what you’re looking for.