About

A mutex is a mutual exclusion object that restricts access to a shared resource (e.g. a file) to a single thread instance.

The mutual exclusion synchronization between concurrent thread means that:

  • only one thread has access to a shared resource
  • while the other threads are waiting

Steps:

  • Before an operation, a thread will lock the mutex before accessing a non-threadsafe resource. This is guaranteed to block the thread until no other thread holds a lock on the mutex and thus enforces exclusive access to the resource.
  • Once the operation is complete, the thread releases the lock, allowing other threads to acquire a lock and access the resource.

It's a mutual exclusive lock.

Library

Documentation / Reference