public abstract class MonitorControl
extends java.lang.Object
Modifier | Constructor and Description |
---|---|
protected |
MonitorControl()
Invoked from subclass constructors.
|
Modifier and Type | Method and Description |
---|---|
static MonitorControl |
getMonitorControl()
Gets the current default monitor control policy.
|
static MonitorControl |
getMonitorControl(java.lang.Object monitor)
Gets the monitor control policy of the given instance of
Object . |
static MonitorControl |
setMonitorControl(MonitorControl policy)
Sets the default monitor control policy.
|
static MonitorControl |
setMonitorControl(java.lang.Object obj,
MonitorControl policy)
Immediately sets
policy as the monitor control policy for
obj . |
public static MonitorControl getMonitorControl(java.lang.Object monitor)
Object
.monitor
- The object being queried.monitor
parameter.StaticIllegalArgumentException
- when monitor
is
null
.public static MonitorControl getMonitorControl()
public static MonitorControl setMonitorControl(MonitorControl policy) throws StaticIllegalArgumentException, StaticUnsupportedOperationException, StaticIllegalStateException
setMonitorControl(Object, MonitorControl)
,
the setting of the default monitor control policy occurs immediately, but
may not be visible on all processors of a multicore system simultaneously.policy
- The new monitor control policy. When null
,
the default MonitorControl
policy is not changed.MonitorControl
policy in effect on completion.StaticSecurityException
- when the caller is not permitted to alter
the default monitor control policy.StaticIllegalArgumentException
- when policy
is
not in immortal memory.StaticUnsupportedOperationException
- when policy
is not
a supported monitor control policy.StaticIllegalStateException
MonitorControl
.public static MonitorControl setMonitorControl(java.lang.Object obj, MonitorControl policy)
policy
as the monitor control policy for
obj
.
Monitor control policy changes on a monitor that is actively contended may lead to queued or enqueuing tasks following either the old or new policy in an unpredictable fashion. Tasks enqueued after the monitor is released after a policy change will follow the new policy.
A thread or schedulable that is queued for the lock
associated with obj
, or is in obj
's wait
set, is not rechecked (e.g., for a
CeilingViolationException
) under policy
,
either as part of the execution of setMonitorControl
or when it is awakened to (re)acquire the lock.
The thread or schedulable invoking
setMonitorControl
must already hold the lock on
obj
.
obj
- The object that will be governed by the new policy.policy
- The new policy for the object. When null
nothing will happen.MonitorControl
policy for
obj
, which will be replaced.StaticIllegalArgumentException
- when obj
is
null
or policy
is not in immortal
memory.StaticUnsupportedOperationException
- when policy
is not
a supported monitor control policy.java.lang.IllegalMonitorStateException
- when the caller does not hold a lock
on obj
.MonitorControl
.