Mutex is a synchronization primitive that can synchronize between processes.
name | illustrate | |
---|---|---|
Mutex() |
Initializes a new instance of the Mutex class with default properties. |
|
Mutex(Boolean) |
Initializes a new instance of the Mutex class with a Boolean value indicating whether the calling thread should have initial ownership of the mutex. |
|
Mutex(Boolean, String) |
Initializes a new instance of the Mutex class with a Boolean value indicating whether the calling thread should have initial ownership of the mutex and whether the string is the name of the mutex . |
|
Mutex(Boolean, String, Boolean) |
Initializes the Mutex with a Boolean value that indicates whether the calling thread should have initial ownership of the mutex and whether the string is the name of the mutex, and a Boolean value that indicates whether the calling thread has given initial ownership of the mutex when the thread returns A new instance of the class. |
|
Mutex(Boolean, String, Boolean, MutexSecurity) |
Use a Boolean value that indicates whether the calling thread should have initial ownership of the mutex and whether the string is the name of the mutex and when the thread returns to indicate whether the calling thread has given initial ownership of the mutex and whether access control is safe A Boolean variable that has been applied to the named mutex initializes a new instance of the Mutex class. |
When used, the WaitOne function and the ReleaseMutex function must be used in pairs.
System.MarshalByRefObject
System.Threading.WaitHandle
System.Threading.Mutex
Mutexes are more advanced than critical sections. Mutexes can be named to support thread synchronization across processes. Mutex is the operation of the called Win32 API on the mutex, so different processes under the same operating system can share the lock according to the name of the mutex.
Because of this, the operation of the mutex will call system resources, and the performance is also reduced relative to the critical section. Using critical sections for thread synchronization within a process will perform better .
Reference link: