Home
Dictionary
Tags
Development
C Sharp
Mutex
Definition - What does
Mutex
mean?
Mutex, in C#, is a class defined in the .NET framework class library that can be used to prevent the simultaneous execution of a block of code by multiple threads that are running in a single or multiple processes.
Mutex is used as a synchronization primitive in situations where a resource has to be shared by multiple threads simultaneously. Named mutex objects are used for inter-process synchronization because multiple applications can access the same mutex object.
The mutex class is designed to protect a shared resource like memory, file handle or network connection from simultaneous access by multiple threads or processes. It is used in lock statement to provide serialized access to resources and ensures mutual exclusion inside the critical sections of code. It helps prevent the unpredictable data corruption that can arise if there is no synchronization. It is often used to check for a single instance of an application at a time.
Mutex is an abbreviated form of mutually exclusive.
Techopedia explains
Mutex
Mutex provides multiple threads with access to a shared resource such that the second thread that needs to acquire a mutex that has already been acquired by another thread has to wait until the instant when the first thread releases the mutex. Care should be taken to ensure that a thread does not attempt to acquire a mutex that it already holds, as this can result in a deadlock.
For example, a mutex can be used to provide exclusive access to a file that has to be read or modified in a multithreaded environment.
Mutex class has a constructor that can be used to specify key parameters of a new mutex object during its initialization, such as name, ownership information and the access control security to be applied to the named mutex.
While lock statements can be used to synchronize threads within a single process, mutex is used across process boundaries.
Since mutex class is a wrapper to a Win32 construct, it requires interop transitions that result in a hit to performance. As such, it is not a good choice unless it is required for reasons like synchronization across process boundaries.
This definition was written in the context of C#.
Posted by:
Cory Janssen
Tweet
Tweet
Related Terms
Object (C#)
Lock Statement (C#)
Thread
Synchronization (.NET)
Constructor
Interoperability
Related Videos
Related Links
Related White Papers
Other Resources
Related Tags
Categories:
Development
.NET
C Sharp
Synonyms:
Mutually Exclusive
Recommended For You
close
An Introduction to Candidate Keys
Read More
ยป
Connect with us
Techopedia on Linkedin
Follow us on LinkedIn
Techopedia on Twitter
'@Techopedia'
Sign up for Techopedia's Free Newsletter!
Sign-In
Join Techopedia
Home
Dictionary
Articles
Tutorials
Newsletters
Menu
Home
Dictionary
Articles
Tech 101
How To
5 Things
IT Careers
History of Tech
Tutorials
Hot Trends
Big Data
Windows 8
Security
Cloud Computing
Data Centers
Mobile Computing
CRM
Green IT
Storage
Virtualization
Online Privacy
Job Roles
Developers
Network Admins
Database Admins
Tech Support
IT Management
Water Cooler
Infographics
Who To Follow
All Topics
Hacking
Online Marketing
Buzzwords and Jargon
Viruses
Operating Systems
Legal
People
Search Engines
World Wide Web
Personal Tech
Gaming
Linux
Internet