|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectCADI.Common.Util.Mutex
public class Mutex
This class implements a mutex where multiple threads can get read permission but only and only thread is allowed to get the write permission.
Usage example:
getReadLock | getWriteLock
releaseLock
| Field Summary | |
|---|---|
private java.util.ArrayList<java.lang.Thread> |
threads
Contains a list of the threads that grants permission to access to the resource. |
private boolean |
writeLock
Indicates if the write access set. |
| Constructor Summary | |
|---|---|
Mutex()
Constructor. |
|
| Method Summary | |
|---|---|
private void |
addThread(java.lang.Thread thread)
Adds a thread to the list of threads. |
private boolean |
findThread(java.lang.Thread thread)
Checks whether a thread is or not in the list of threads. |
void |
getReadLock()
Gets a lock that grants permission to read. |
void |
getWriteLock()
Gets a lock that grants permission to write. |
void |
releaseLock()
Release the lock (read or write). |
private void |
removeThread(java.lang.Thread thread)
Removes a thread from the list of the threads. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.util.ArrayList<java.lang.Thread> threads
private boolean writeLock
| Constructor Detail |
|---|
public Mutex()
| Method Detail |
|---|
public void getReadLock()
public void getWriteLock()
public void releaseLock()
private boolean findThread(java.lang.Thread thread)
thread - the thread to find.
true if the thread is in the thread list. Otherwise,
returns false.private void addThread(java.lang.Thread thread)
thread - the thread to be added to the list.private void removeThread(java.lang.Thread thread)
thread - the thread to be removed from the thread list.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||