|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.ucla.stat.SOCR.JRI.Mutex
public class Mutex
This class implements a (not so) simple mutex. The initial state of the mutex is unlocked.
Field Summary | |
---|---|
static boolean |
verbose
|
Constructor Summary | |
---|---|
Mutex()
|
Method Summary | |
---|---|
void |
lock()
locks the mutex. |
boolean |
lockWithTimeout(long to)
locks the mutex. |
boolean |
safeLock()
Locks the mutex. |
boolean |
safeLockWithTimeout(long to)
Locks the mutex. |
java.lang.String |
toString()
|
int |
tryLock()
attempts to lock the mutex and returns information about its success. |
void |
unlock()
unlocks the mutex. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static boolean verbose
Constructor Detail |
---|
public Mutex()
Method Detail |
---|
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()
, 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()
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |