|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object monitor.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 AbstractMonitor
public void enter()
AbstractMonitor
A thread must not attempt to enter a Monitor it is already in.
enter
in class AbstractMonitor
public void leave()
AbstractMonitor
Only a thread that is in the monitor may leave it.
leave
in class AbstractMonitor
public <T> T leave(T result)
AbstractMonitor
Only a thread that is in the monitor may leave it.
leave
in class AbstractMonitor
public void doWithin(java.lang.Runnable runnable)
AbstractMonitor
Any 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 AbstractMonitor
runnable
- A Runnable object.public <T> T doWithin(RunnableWithResult<T> runnable)
AbstractMonitor
Any 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 AbstractMonitor
runnable
- A RunnableWithResult object.
public Condition makeCondition()
AbstractMonitor
makeCondition
in class AbstractMonitor
public Condition makeCondition(Assertion assertion)
AbstractMonitor
makeCondition
in class AbstractMonitor
public 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 |