All Packages This Package Class Hierarchy Class Search Index
java.lang.Object | +----com.hermetica.util3d.CriticalSection
| Summary |
public class CriticalSection
extends java.lang.Object
{
// Constructors 5
public CriticalSection();
public CriticalSection(boolean);
public CriticalSection(String);
public CriticalSection(String, boolean);
public CriticalSection(String, boolean, PrintStream);
// Methods 7
public String getName();
public boolean getTraceStatus();
public synchronized void lock();
public void setName(String);
public void setOutputStream(PrintStream);
public void setTraceStatus(boolean);
public synchronized void unlock();
}
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''.
| Cross Reference |
| Constructors |
· CriticalSection | Summary | Top |
public CriticalSection()
Create a new anonymous lock object
· CriticalSection | Summary | Top |
public CriticalSection(String name)
Create a new lock object with the specified name
· CriticalSection | Summary | Top |
public CriticalSection(boolean mode)
Create a new anonymous lock object with the specified tracing mode
· CriticalSection | Summary | Top |
public CriticalSection(String name,
boolean mode)
Create a new named lock object with the specified name and tracing mode
· CriticalSection | Summary | Top |
public CriticalSection(String name,
boolean mode,
PrintStream oStream)
Create a new named lock with the given tracing mode and the given output stream for the trace output
| Methods |
· setTraceStatus | Summary | Top |
public void setTraceStatus(boolean mode)
Sets the tracing level of this lock
· getTraceStatus | Summary | Top |
public boolean getTraceStatus()
Returns the tracing level of the lock
· setName | Summary | Top |
public void setName(String name)
Sets the name of the lock
· getName | Summary | Top |
public String getName()
Returns the name of the lock
· setOutputStream | Summary | Top |
public void setOutputStream(PrintStream oStream)
Sets the output stream for the trace output
· lock | Summary | Top |
public synchronized void lock()
Begins a critical section of code
· unlock | Summary | Top |
public synchronized void unlock()
Ends a critical section of code
All Packages This Package Class Hierarchy Class Search IndexFreshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7