public static final class Mutex.Privileged extends Object
try { enterXAccess (); yourCustomMethod (); } finally { exitXAccess (); }can be used. You must, however, control the related Mutex, i.e. you must be creator of the Mutex.
Constructor and Description |
---|
Privileged() |
Modifier and Type | Method and Description |
---|---|
void |
enterReadAccess() |
void |
enterWriteAccess() |
void |
exitReadAccess() |
void |
exitWriteAccess() |
boolean |
tryReadAccess(long timeout)
Tries to obtain read access.
|
boolean |
tryWriteAccess(long timeout)
Tries to obtain write access.
|
public void enterReadAccess()
public boolean tryReadAccess(long timeout)
timeout
- amount of milliseconds to wait before giving up.
0
means to wait indefinitely.
-1
means to not wait at all and immediately exittrue
if the access has been granted,
false
otherwisepublic void enterWriteAccess()
public boolean tryWriteAccess(long timeout)
timeout
- amount of milliseconds to wait before giving up.
0
means to wait indefinitely.
-1
means to not wait at all and immediately exittrue
if the access has been granted,
false
otherwisepublic void exitReadAccess()
public void exitWriteAccess()