|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.commons.util.ThreadLockManager
public class ThreadLockManager
Read write lock acquisition.
Locking strategies can be defined by overriding some of the protected methods (who has priority, how many concurrent thread can run simultaneously...). Also note that JRE 5 now has a concurrent package which can be used to replace this class.
Inspired from 'Concurrent programming in Java, 2nd edition'
Field Summary | |
---|---|
protected int |
activeReaders
|
protected int |
activeWriters
|
protected int |
waitingReaders
|
protected int |
waitingWriters
|
Constructor Summary | |
---|---|
ThreadLockManager()
|
Method Summary | |
---|---|
protected void |
afterRead(java.lang.Object param)
|
protected void |
afterWrite(java.lang.Object param)
|
protected boolean |
allowReader(java.lang.Object param)
|
protected boolean |
allowWriter(java.lang.Object param)
|
protected void |
beforeRead(java.lang.Object param)
|
protected void |
beforeWrite(java.lang.Object param)
|
protected void |
doRead()
|
protected void |
doWrite()
|
ThreadLock |
getReadLock()
Get a lock used to read data. |
ThreadLock |
getReadLock(java.lang.Object param)
Get a lock used to read data. |
ThreadLock |
getWriteLock()
Get a lock used to write data. |
ThreadLock |
getWriteLock(java.lang.Object param)
Get a lock used to write data. |
void |
read()
|
void |
read(java.lang.Object param)
|
protected boolean |
tryBeforeRead(java.lang.Object param)
|
protected boolean |
tryBeforeWrite(java.lang.Object param)
|
protected void |
waitForRead(java.lang.Object param)
|
protected void |
waitForWrite(java.lang.Object param)
|
void |
write()
|
void |
write(java.lang.Object param)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int activeReaders
protected int activeWriters
protected int waitingReaders
protected int waitingWriters
Constructor Detail |
---|
public ThreadLockManager()
Method Detail |
---|
protected boolean allowReader(java.lang.Object param)
protected boolean allowWriter(java.lang.Object param)
protected void beforeRead(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void waitForRead(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
protected boolean tryBeforeRead(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void afterRead(java.lang.Object param)
protected void beforeWrite(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void waitForWrite(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
protected boolean tryBeforeWrite(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void afterWrite(java.lang.Object param)
public void read() throws java.lang.InterruptedException
java.lang.InterruptedException
public void read(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
public void write() throws java.lang.InterruptedException
java.lang.InterruptedException
public void write(java.lang.Object param) throws java.lang.InterruptedException
java.lang.InterruptedException
protected void doRead()
protected void doWrite()
public ThreadLock getReadLock()
public ThreadLock getReadLock(java.lang.Object param)
public ThreadLock getWriteLock()
public ThreadLock getWriteLock(java.lang.Object param)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |