public class Mutex extends Object
| Modifier and Type | Field and Description |
|---|---|
static boolean |
verbose |
| Constructor and Description |
|---|
Mutex() |
| Modifier and Type | Method and Description |
|---|---|
void |
lock()
locks the mutex.
|
boolean |
lockWithTimeout(long to)
locks the mutex.
|
boolean |
safeLock()
Locks the mutex.
|
boolean |
safeLockWithTimeout(long to)
Locks the mutex.
|
String |
toString() |
int |
tryLock()
attempts to lock the mutex and returns information about its success.
|
void |
unlock()
unlocks the mutex.
|
public void lock()
safeLock() instead if you wish to detect such deadlocks.public boolean lockWithTimeout(long to)
to - timeout in milliseconds, see Object.wait().true if the lock was successful, false if notpublic int tryLock()
lock() would cause a deadlock).public boolean safeLock()
lock() except that it returns immediately if the same thread already owns the lock. It is safer to use this function rather than lock(), because lock can possibly cause a deadlock which won't be resolved.true is the mutex was successfully locked, false if deadlock was detected (i.e. the same thread has already the lock).public boolean safeLockWithTimeout(long to)
lockWithTimeout(long) except that it returns immediately if the same thread already owns the lock. It is safer to use this function rather than lockWithTimeout(long), because lock can possibly cause a deadlock which won't be resolved.true is the mutex was successfully locked, false if deadlock was detected or timeout elapsed.public void unlock()
Copyright © 2017. All rights reserved.