public class ThreadConstraint extends ResourceConstraint<ThreadConstraint>
ThreadGroup
and
RealtimeThreadGroup
, instances of ProcessingConstraint
can be nested. The number of the threads, including threads in
subgroups not subject to another ProcessingConstraint
instance, can be both tracked and bounded.Constructor and Description |
---|
ThreadConstraint(RealtimeThreadGroup group,
int max)
Creates a
ThreadConstraint to govern a group of threads. |
Modifier and Type | Method and Description |
---|---|
int |
available()
Gets the number of threads that still may be created.
|
static ThreadConstraint |
currentConstraint()
Determine the processing constraint for the current execution context.
|
static ThreadConstraint |
currentConstraint(java.lang.Thread thread)
Determine the processing constraint for the give execution context.
|
static ThreadConstraint |
currentConstraint(java.lang.ThreadGroup group)
Determine the thread constraint for the give execution context.
|
int |
getBudget()
Get the number of threads that may be created in this group.
|
static ThreadConstraint |
getRootConstraint()
Get the root instance for this constraint type.
|
boolean |
isEnforcing()
Determine whether or not enforcing is in effect.
|
void |
start()
Start applying this constraint to is tasks.
|
void |
stop()
Stop applying this constraint to is tasks.
|
int |
used()
Gets the cost used in the current period so far.
|
getNotificationHandler, getParent, getRealtimeThreadGroup, governs, governs, governs, setNotificationHandler, visitBorrowers, visitGoverned
public ThreadConstraint(RealtimeThreadGroup group, int max)
ThreadConstraint
to govern a group of threads.group
- The RealtimeThreadGroup
to govern.max
- The maximum number of threads allowed.public static ThreadConstraint getRootConstraint()
public static ThreadConstraint currentConstraint()
public static ThreadConstraint currentConstraint(java.lang.Thread thread)
thread
- The given execution context.public static ThreadConstraint currentConstraint(java.lang.ThreadGroup group)
group
- The given execution context.public boolean isEnforcing()
isEnforcing
in class ResourceConstraint<ThreadConstraint>
true
when yes and false
when not.public void start()
start
in class ResourceConstraint<ThreadConstraint>
public void stop()
stop
in class ResourceConstraint<ThreadConstraint>
public int getBudget()
public int used()
public int available()