|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectibis.util.Monitor
Monitor synchronization construct.
The Monitor can be entered (lock()
) and exited
(unlock()
). ConditionVariable
s that are part of this
monitor can be obtained by createCV()
.
The Monitor has optional support for priority locking. If the Monitor is
unlocked and some thread has locked it with priority = true
,
that thread has preference in waking up above nonpriority lockers.
Constructor Summary | |
Monitor()
Constructs a Monitor , without support for priority locking. |
|
Monitor(boolean priority)
Constructs a Monitor . |
Method Summary | |
void |
checkImNotOwner()
When debugging is enabled, throws an exception when the current thread owns the Monitor. |
void |
checkImOwner()
When debugging is enabled, throws an exception when the current thread does not own the Monitor. |
ConditionVariable |
createCV()
Creates a ConditionVariable associated with this Monitor. |
ConditionVariable |
createCV(boolean interruptible)
Creates a ConditionVariable associated with this Monitor. |
java.lang.Thread |
getOwner()
|
void |
lock()
Enters the Monitor, without priority over other threads. |
void |
lock(boolean priority)
Enters the Monitor. |
static void |
report(java.io.PrintStream out)
When statistics are enabled, this method prints some on the stream given. |
boolean |
tryLock()
|
void |
unlock()
Leaves the Monitor, making it available for other threads. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Monitor(boolean priority)
Monitor
. The parameter indicates wether
it must have support for priority locking.
priority
- when true
, priority locking will be
supported.public Monitor()
Monitor
, without support for priority locking.
Method Detail |
public void lock()
public void lock(boolean priority)
priority
- when true
, this thread has priority over
nonpriority lockers.public boolean tryLock()
public void unlock()
public ConditionVariable createCV()
ConditionVariable
associated with this Monitor.
public ConditionVariable createCV(boolean interruptible)
ConditionVariable
associated with this Monitor.
interruptible
- when true
,
Thread.interrupt()
ing
the Thread
that is waiting on this Condition Variable causes
the waiting thread to return with an InterruptedException
.
Non-interruptible Condition Variables ignore Thread.interrupt()
.public final void checkImOwner()
IllegalLockStateException
- is thrown when the current thread
does not own the Monitor.public final void checkImNotOwner()
IllegalLockStateException
- is thrown when the current thread owns
the Monitor.public static void report(java.io.PrintStream out)
out
- the stream to print on.public java.lang.Thread getOwner()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |