|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjsync.Lock
Class for supporting resource locking. Lock can be exclusive or shared, so multiple-readers single-writer protocol can be implemented. Locks can be nested, i.e. a thread can set a lock several times and resources will be unlocked only after execution of correspondent number of unlock requests.
Constructor Summary | |
Lock()
|
Method Summary | |
void |
setExclusive()
Lock resource in exclusive mode without limitation of waiting time. |
boolean |
setExclusive(long timeout)
Lock resource in exclusive mode. |
void |
setShared()
Lock resource in shared mode without limitation of waiting time. |
boolean |
setShared(long timeout)
Lock resource in shared mode. |
void |
unsetExclusive()
Release exclusive lock. |
void |
unsetShared()
Release shared lock. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Lock()
Method Detail |
public boolean setShared(long timeout)
timeout
- the maximum time to wait in milliseconds.
true
if lock is successfully set,
false
if resource can't be locked before expiration
of timeout.public void setShared()
public boolean setExclusive(long timeout)
timeout
- the maximum time to wait in milliseconds.
true
if lock is successfully set,
false
if resource can't be locked within specified time.public void setExclusive()
public void unsetShared()
NotOwnerError
if shared
lock was not previously set by this thread.
public void unsetExclusive()
unsetExclusive
requests.
Throws NotOwnerError
if exclusive lock was not previously
set by this thread.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |