public class RealtimeThreadGroup extends ThreadGroup
ThreadGroup
in which a RealtimeThread
instance
may be started, as well as a convention Thread
. Limits for what
realtime scheduler and scheduling parameters can be enforced on all tasks
in this group. A normal ThreadGroup
may not contain an instance of
Schedulable
, but may contain other instances of
RealtimeThreadGroup
to form a hierarchy. Every thread is in some
instance of ThreadGroup
and every instance of RealtimeThread
is in some instance of RealtimeThreadGroup
.
Please note that some of the method of this class are not thread safe, as they
use methods from ThreadGroup that are not thread safe.Constructor and Description |
---|
RealtimeThreadGroup(RealtimeThreadGroup parent,
String name)
Creates a new realtime thread group with its scheduler type inherited from
parent . |
RealtimeThreadGroup(RealtimeThreadGroup parent,
String name,
Class<? extends Scheduler> scheduler)
Creates a new realtime thread group with its scheduler type inherited from
parent . |
RealtimeThreadGroup(String name)
Creates a new group with the current
ThreadGroup instance
as its parent and that parent's scheduler type for its scheduler type. |
Modifier and Type | Method and Description |
---|---|
SchedulingParameters |
getMaxEligibility()
Finds the upper bound on scheduling eligibility that tasks in this
group may have.
|
Class<? extends Scheduler> |
getScheduler()
Finds the type of scheduler tasks in this group may use.
|
RealtimeThreadGroup |
setMaxEligibility(SchedulingParameters parameters)
Sets the upper bound on scheduling eligibility that tasks in this
group may have.
|
void |
visitChildren(Consumer<ThreadGroup> visitor)
Performs some operation on all the children of the current group.
|
void |
visitChildren(Consumer<ThreadGroup> visitor,
boolean recursive)
Performs some operation on all the children of the current group.
|
void |
visitConventionalThreads(Consumer<Thread> visitor)
|
void |
visitConventionalThreads(Consumer<Thread> visitor,
boolean recurse)
Visit all
java.lang.Thread instances that are not instances of
Schedulable contained by this group and optionally all
ThreadGroup instances contained within recursively. |
void |
visitSchedulables(Consumer<Schedulable> visitor)
|
void |
visitSchedulables(Consumer<Schedulable> visitor,
boolean recurse)
Visit all
Schedulable instances contained by this group
and optionally all ThreadGroup instances contained within
recursively. |
activeCount, activeGroupCount, allowThreadSuspension, checkAccess, destroy, enumerate, enumerate, enumerate, enumerate, getMaxPriority, getName, getParent, interrupt, isDaemon, isDestroyed, list, parentOf, resume, setDaemon, setMaxPriority, stop, suspend, toString, uncaughtException
public RealtimeThreadGroup(RealtimeThreadGroup parent, String name, Class<? extends Scheduler> scheduler)
parent
.StaticIllegalStateException
- when the parent ThreadGroup
instance is not an instance of RealtimeThreadGroup
.IllegalAssignmentError
- when the parent ThreadGroup
instance is not assignable to this.parent
- The parent group of the new groupname
- The name of the new groupscheduler
- a scheduler class limiting the schedulers allowed for
scheduling group members. When null
inherits from parent.
Instances of java.lang.ThreadGroup
do not have a scheduler
and may not contain instances of RealtimeSchedulerGroup
.public RealtimeThreadGroup(RealtimeThreadGroup parent, String name) throws StaticIllegalStateException, IllegalAssignmentError
parent
.StaticIllegalStateException
- when the parent ThreadGroup
instance is not an instance of RealtimeThreadGroup
.IllegalAssignmentError
- when the parent
ThreadGroup
instance is not assignable to this.parent
- The parent group of the new groupname
- The name of the new grouppublic RealtimeThreadGroup(String name) throws StaticIllegalStateException, IllegalAssignmentError
ThreadGroup
instance
as its parent and that parent's scheduler type for its scheduler type.
That parent must be an instance of RealtimeThreadGroup
.
The primordial realtime thread group has Scheduler.class
as its
scheduler type.StaticIllegalStateException
- when the parent ThreadGroup
instance is not an instance of RealtimeThreadGroup
.IllegalAssignmentError
- when the parent
ThreadGroup
instance is not assignable to this.name
- The name of the new grouppublic Class<? extends Scheduler> getScheduler()
class<Scheduler>
, but it may be set to any subtype.public SchedulingParameters getMaxEligibility()
PriorityParameters
, it gives the maximum base priority any
task in this group.null
when no such bound has been specified.public RealtimeThreadGroup setMaxEligibility(SchedulingParameters parameters) throws StaticIllegalStateException
PriorityParameters
, it sets the maximum base priority any
task in this group may have. When a task in the group has a higher
eligibility than specified in parameters
, the task's
eligibility is silently set to the max specified in parameters
.
When the new eligibility is higher than that of any parent's eligibility,
then eligibility is set to the minimum of those priorities.
When a child of this
RealtimeThreadGroup
has a higher max eligibility than specified in
parameters
, its max eligibility is silently set to the max
specified in parameters
as if setMaxEligibility
were
invoked on it recursively.
When a task in this RealtimeThreadGroup
or a child of this
RealtimeThreadGroup
has previously had its maximum eligibility
reduced by a call to this method, setting a higher maximum
eligibility via this method will not automatically reraise its
eligibility.
Please note that this method is not thread safe, as it uses methods
from ThreadGroup that are not thread safe.
StaticIllegalArgumentException
- when parameters
are not
consistent with the scheduler type. The scheduler specified
must be specific enough that only mutually compatible
SchedulingParameters
could be set. For example,
Scheduler
is not sufficient to restrict the scheduling
parameters to compatible types, but PriorityScheduler
does
since all PriorityScheduler
instances require
PriorityParameters
.StaticIllegalStateException
- when parameters
is a
higher eligibility than the max eligibility enforced by a
SchedulingParameters
above this
in the
hierarchy.parameters
- The SchedulingParameter instance denoting the new
upper bound on the scheduling eligibility of threads in this group.this
public void visitConventionalThreads(Consumer<Thread> visitor, boolean recurse) throws ForEachTerminationException
java.lang.Thread
instances that are not instances of
Schedulable
contained by this
group and optionally all
ThreadGroup
instances contained within recursively.
Please note that this method is not thread safe, as it uses methods
from ThreadGroup that are not thread safe.ForEachTerminationException
- when the visitor is prematurely ended.visitor
- A consumer of each conventional instance.recurse
- A boolean to indicated that the visit should be recursive.public void visitConventionalThreads(Consumer<Thread> visitor) throws ForEachTerminationException
visitConventionalThreads(Consumer, boolean)
with
recurse
set to false
.
Please note that this method is not thread safe, as it uses methods
from ThreadGroup that are not thread safe.ForEachTerminationException
- when the traversal ends prematurelyvisitor
- A consumer of each conventional thread instancepublic void visitSchedulables(Consumer<Schedulable> visitor, boolean recurse) throws ForEachTerminationException
Schedulable
instances contained by this
group
and optionally all ThreadGroup
instances contained within
recursively.
Please note that this method is not thread safe, as it uses methods
from ThreadGroup that are not thread safe.ForEachTerminationException
- when the traversal ends prematurelyvisitor
- A consumer of each schedulable instance.recurse
- A boolean to indicated that the visit should be recursive.public void visitSchedulables(Consumer<Schedulable> visitor) throws ForEachTerminationException
visitSchedulables(Consumer, boolean)
with
recurse
set to false
.
Please note that this method is not thread safe, as it uses methods
from ThreadGroup that are not thread safe.ForEachTerminationException
- when the traversal ends prematurelyvisitor
- A consumer of each schedulable instancepublic void visitChildren(Consumer<ThreadGroup> visitor, boolean recursive)
visitor
does not
throw a ForEachTerminationException
. Thus the traversal can be
prematurely ended by visitor
throwing this exception, e.g., when
a particular element is found.
Please note that this method is not thread safe, as it uses methods
from ThreadGroup that are not thread safe.ForEachTerminationException
- when the traversal ends prematurely.visitor
- The function to be called on each child thread group.recursive
- A boolean to determine whether or not all subgroups
are included, where true
means yes and false
means no.public void visitChildren(Consumer<ThreadGroup> visitor) throws ForEachTerminationException
visitor
does not
throw a ForEachTerminationException
. Thus the traversal can be
prematurely ended by visitor
throwing this exception, e.g., when
a particular element is found.
Please note that this method is not thread safe, as it uses methods
from ThreadGroup that are not thread safe.ForEachTerminationException
- when the traversal ends prematurely.visitor
- The function to be called on each child thread group.aicas GmbH, Karlsruhe, Germany —www.aicas.com
Copyright © 2001-2019 aicas GmbH. All Rights Reserved.