|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.hermetica.util3d.CriticalSection
This class acts as a sort of mutex that provides exclusive access to ``critical sections'' of code. You can acquire ( or attempt to acquire ) a lock via the ``lock'' method. Similarly, ``unlock'' will release the lock for other waiters to fight for!
This code is based on an original by Jason Osgood who similarly was inspired by Doug Lea's ``Concurrent Programming in Java''.
Constructor Summary | |
CriticalSection()
Create a new anonymous lock object |
|
CriticalSection(boolean mode)
Create a new anonymous lock object with the specified tracing mode |
|
CriticalSection(java.lang.String name)
Create a new lock object with the specified name |
|
CriticalSection(java.lang.String name,
boolean mode)
Create a new named lock object with the specified name and tracing mode |
|
CriticalSection(java.lang.String name,
boolean mode,
java.io.PrintStream oStream)
Create a new named lock with the given tracing mode and the given output stream for the trace output |
Method Summary | |
java.lang.String |
getName()
Returns the name of the lock |
boolean |
getTraceStatus()
Returns the tracing level of the lock |
void |
lock()
Begins a critical section of code |
void |
setName(java.lang.String name)
Sets the name of the lock |
void |
setOutputStream(java.io.PrintStream oStream)
Sets the output stream for the trace output |
void |
setTraceStatus(boolean mode)
Sets the tracing level of this lock |
void |
unlock()
Ends a critical section of code |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public CriticalSection()
public CriticalSection(java.lang.String name)
public CriticalSection(boolean mode)
public CriticalSection(java.lang.String name, boolean mode)
public CriticalSection(java.lang.String name, boolean mode, java.io.PrintStream oStream)
Method Detail |
public void setTraceStatus(boolean mode)
public boolean getTraceStatus()
public void setName(java.lang.String name)
public java.lang.String getName()
public void setOutputStream(java.io.PrintStream oStream)
public void lock()
public void unlock()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |