mutex

A mutex is a mutual exclusion lock. When a mutex is held by one thread, it prevents other threads from gaining hold of the mutex.

The thread package also supports a read-write “mutex”, which allows many readers to hold the mutex at once, but when some writer thread wants the mutex, it waits to gain it exclusively.