w10schools
Login Register
  • Home
  • Tutorials
    • HTML, CSS
      • HTML, HTML5
      • CSS, CSS3
    • XML
    • JavaScript, AJAX
    • PHP
    • Ruby on Rails
      • Ruby
      • Rails
    • ASP.NET
      • ASP
      • C# .NET
    • Java
      • JSP
    • Databases
      • MySQL
      • MSSQL Server
      • Oracle
    • Web Server
      • Windows
      • Linux
      • Apache
      • IIS
    • Design
      • Dreamweaver
      • Flash
      • Photoshop
      • Fireworks
      • CorelDRAW
      • Illustrator
  • References
    • HTML
      • Bootstrap
    • CSS
      • CSS Selectors
      • Sass
    • JavaScript
    • Mobile Apps
      • Cordova
    • Ruby on Rails
      • Ruby
      • Rails
    • PHP
      • Function
      • Language
      • CodeIgniter
      • Phalcon
      • PHPUnit
      • Symfony
      • Drupal
      • Yii
      • Laravel
    • Perl
      • Perl
    • Python
      • Python
      • Django
      • NumPy
      • Pandas
      • scikit-image
      • scikit-learn
      • Statsmodels
      • Matplotlib
    • Lua
      • Lua
    • C, C++
      • C
      • C++
    • Server
      • Docker
      • Apache HTTP Server
      • Nginx
    • Database
      • PostgreSQL
    • Big Data
      • TensorFlow
    • Game Development
      • Phaser
      • LÖVE
  • Articles
    • News
    • General
      • Website Promotion
      • Online Advertising
      • Make Money Online
    • Editorials
    • Interviews
    • Web Roundups
  • Resources
    • Design
      • Fonts
      • Graphics
      • Vectors
      • Templates
      • UI (User Interface)
      • Brushes
      • Patterns, Backgrounds
      • Textures
    • Web Development
      • HTML, CSS
      • XML
      • JavaScript, AJAX
      • Ruby on Rails
      • PHP
      • Java
      • .NET
      • Python
      • Perl
      • Flash
    • Mobile Application Development
      • Mobile Development Tools
      • Swift
    • Online Services
      • Online Storage
      • Web Hosting
  • Tools
    • Generators
  • References
  • Ruby on Rails
  • Ruby
  • Classes
  • Mutex
×
Type:
Class

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

Example:

require 'thread'
semaphore = Mutex.new

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

b = Thread.new {
  semaphore.synchronize {
    # access shared resource
  }
}
lock
  • References/Ruby on Rails/Ruby/Classes/Mutex

mutex.lock â self Instance Public methods Attempts to grab the lock and waits

2025-01-10 15:47:30
new
  • References/Ruby on Rails/Ruby/Classes/Mutex

Mutex.new â mutex Class Public methods Creates a new

2025-01-10 15:47:30
try_lock
  • References/Ruby on Rails/Ruby/Classes/Mutex

mutex.try_lock â true or false Instance Public methods Attempts to obtain

2025-01-10 15:47:30
owned?
  • References/Ruby on Rails/Ruby/Classes/Mutex

mutex.owned? â true or false Instance Public methods Returns true

2025-01-10 15:47:30
sleep
  • References/Ruby on Rails/Ruby/Classes/Mutex

mutex.sleep(timeout = nil) â number Instance Public methods Releases the

2025-01-10 15:47:30
locked?
  • References/Ruby on Rails/Ruby/Classes/Mutex

mutex.locked? â true or false Instance Public methods Returns true

2025-01-10 15:47:30
unlock
  • References/Ruby on Rails/Ruby/Classes/Mutex

mutex.unlock â self Instance Public methods Releases the lock. Raises

2025-01-10 15:47:30
synchronize
  • References/Ruby on Rails/Ruby/Classes/Mutex

mutex.synchronize { ... } â result of the block Instance Public methods Obtains

2025-01-10 15:47:30
Popular Articles
pyplot pyplot matplotlib.pyplot Provides a MATLAB-like plotting framework. pylab combines pyplot with numpy into a single namespace. This is convenient for
Ion.RangeSlider - jQuery range slider with skin support Ion.RangeSlider is an easily customizable jQuery range slider. It has flexible settings and can be completely altered with CSS.   Ion.RangeSlider - 
Types Types JavaScript provides several built-in datatypes. In addition to those, this page documents virtual types like Selectors, enhanced pseudo-types
perlapi - autogenerated documentation for the perl public API NAME DESCRIPTION "Gimme" Values Array Manipulation Functions xsubpp variables and internal functions Callback Functions Character case changing Char
1. Overview This is a practical guide to Angular for experienced programmers who are building client applications in HTML and TypeScript. Organization The docu


  • Facebook
  • Tweet
  • Digg it
  • Stumbleupon
  • Delicious
  • Plus Share

Designed by : w10schools

service@w10schools.com

Our Partners: aeeble – Providing content publishing and search solutions