libperun

Class std.mt.Mutex

Synopsis

public final class Mutex

Represents a recursive mutual exclusion lock (mutex).

Fields

Constructors

public Mutex();

Constructor. The mutex is initially unlocked.

Methods

public void lock();

Lock the mutex.

If a mutex is recursively locked multiple times by the same thread, then it remains locked until unlock() is called an equal number of times. If the mutex is currently locked by another thread, then this method will wait until it is unlocked by its current owner.

Incorrect use can result in deadlock situations. If a deadlock situation is successfully detected by the library, the program will abort immediately (rather than throw an exception!).

public void unlock();

Unlock the mutex.

If the calling thread does not own the mutex, it is an error. The behavior is undefined, but if this situation is successfully detected, then the program will abort immediately (rather than throw an exception!).