|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectmonitor.AbstractMonitor
monitor.Monitor
public final class Monitor
A final class for Monitors.
Use an object of this class if you want to use delegation.
Extend AbstractMonitor, if you want to use inheritance.
The methods have the same meaning as in AbstractMonitor, but here they are public.
AbstractMonitor,
Condition| Constructor Summary | |
|---|---|
Monitor()
|
|
Monitor(Assertion invariant)
|
|
Monitor(java.lang.String name)
|
|
Monitor(java.lang.String name,
Assertion invariant)
|
|
| Method Summary | ||
|---|---|---|
void |
doWithin(java.lang.Runnable runnable)
Run the runnable inside the monitor. |
|
|
doWithin(RunnableWithResult<T> runnable)
Run the runnable inside the monitor. |
|
void |
enter()
Enter the monitor. |
|
boolean |
invariant()
The invariant. |
|
void |
leave()
Leave the monitor. |
|
|
leave(T result)
Leave the monitor. |
|
Condition |
makeCondition()
Create a condition queue with no associated checked Assertion. |
|
Condition |
makeCondition(Assertion assertion)
Create a condition queue associated with a checked Assertion. |
|
Condition |
makeCondition(java.lang.String name)
Create a condition queue with no associated checked Assertion. |
|
Condition |
makeCondition(java.lang.String name,
Assertion assertion)
Create a condition queue associated with a checked Assertion. |
|
| Methods inherited from class monitor.AbstractMonitor |
|---|
addListener, getName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Monitor()
public Monitor(Assertion invariant)
public Monitor(java.lang.String name)
public Monitor(java.lang.String name,
Assertion invariant)
| Method Detail |
|---|
public boolean invariant()
AbstractMonitor
invariant in class AbstractMonitorpublic void enter()
AbstractMonitorA thread must not attempt to enter a Monitor it is already in.
enter in class AbstractMonitorpublic void leave()
AbstractMonitorOnly a thread that is in the monitor may leave it.
leave in class AbstractMonitorpublic <T> T leave(T result)
AbstractMonitorOnly a thread that is in the monitor may leave it.
leave in class AbstractMonitorpublic void doWithin(java.lang.Runnable runnable)
AbstractMonitorAny thread calling this method will be delayed until the monitor is empty. The "run" method of its argument is then executed within the protection of the monitor.
When the run method returns, if the thread still occupies the monitor, it leaves the monitor.
doWithin in class AbstractMonitorrunnable - A Runnable object.public <T> T doWithin(RunnableWithResult<T> runnable)
AbstractMonitorAny thread calling this method will be delayed until the monitor is empty. The "run" method of its argument is then executed within the protection of the monitor.
When the run method returns, if the thread still occupies the monitor, it leaves the monitor.
Thus the signalAndLeave method may be called within the run method.
doWithin in class AbstractMonitorrunnable - A RunnableWithResult object.
public Condition makeCondition()
AbstractMonitor
makeCondition in class AbstractMonitorpublic Condition makeCondition(Assertion assertion)
AbstractMonitor
makeCondition in class AbstractMonitorpublic Condition makeCondition(java.lang.String name)
AbstractMonitor
makeCondition in class AbstractMonitor
public Condition makeCondition(java.lang.String name,
Assertion assertion)
AbstractMonitor
makeCondition in class AbstractMonitor
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||