Class for providing mutual exclusion of threads. Only one thread can enter
critical section guarded by mutex (but can do it several times).
- public class Mutex
- extends java.lang.Object
|| enter(long timeout)
Try to lock mutex within specified period of time.
|Methods inherited from class java.lang.Object
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
public void enter()
- Lock mutex. This method should be called before entering critical
public boolean enter(long timeout)
- Try to lock mutex within specified period of time. This method
should be called before entering critical section.
- the maximum time to wait in milliseconds.
true if mutex is successfully locked,
enter() was terminated
due to timeout expiration.
public void leave()
- Release mutex. This method should be called after exit from critical
section. Mutex will be unlocked only if number of
invocations is equal to the number of