class Thread::Mutex

Parent:
Object

Thread::Mutex implements a simple semaphore that can be used to coordinate access to shared data from multiple concurrent threads.

Example:

semaphore = Thread::Mutex.new

a = Thread.new {
  semaphore.synchronize {
    # access shared resource
  }
}

b = Thread.new {
  semaphore.synchronize {
    # access shared resource
  }
}

Ruby Core © 1993–2024 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.