java.lang.Object | |
↳ | java.lang.ThreadGroup |
ThreadGroup
is a means of organizing threads into a hierarchical structure.
This class is obsolete. See Effective Java Item 73, "Avoid thread groups" for details.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
ThreadGroup with the given name. | |||||||||||
Constructs a new
ThreadGroup with the given name, as a child of the
given ThreadGroup . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the number of running
Thread s which are children of this thread group,
directly or indirectly. | |||||||||||
Returns the number of
ThreadGroup s which are children of this group,
directly or indirectly. | |||||||||||
This method is deprecated.
Required deprecated method suspend().
| |||||||||||
Does nothing.
| |||||||||||
Destroys this thread group and recursively all its subgroups.
| |||||||||||
Iterates over all active threads in this group (and its sub-groups) and
stores the threads in the given array.
| |||||||||||
Iterates over all thread groups in this group (and, optionally, its
sub-groups) and stores the groups in the given array.
| |||||||||||
Iterates over all active threads in this group (and, optionally, its
sub-groups) and stores the threads in the given array.
| |||||||||||
Iterates over all thread groups in this group (and its sub-groups) and
and stores the groups in the given array.
| |||||||||||
Returns the maximum allowed priority for a
Thread in this thread group. | |||||||||||
Returns the name of this thread group.
| |||||||||||
Returns this thread group's parent
ThreadGroup . | |||||||||||
Interrupts every
Thread in this group and recursively in all its
subgroups. | |||||||||||
Checks whether this thread group is a daemon
ThreadGroup . | |||||||||||
Checks whether this thread group has already been destroyed.
| |||||||||||
Outputs to
System.out a text representation of the
hierarchy of Thread s and ThreadGroup s in this thread group (and recursively). | |||||||||||
Checks whether this thread group is a direct or indirect parent group of a
given
ThreadGroup . | |||||||||||
This method is deprecated.
Requires deprecated method Thread.resume().
| |||||||||||
Sets whether this is a daemon
ThreadGroup or not. | |||||||||||
Configures the maximum allowed priority for a
Thread in this group and
recursively in all its subgroups. | |||||||||||
This method is deprecated.
Requires deprecated method Thread.stop().
| |||||||||||
This method is deprecated.
Requires deprecated method Thread.suspend().
| |||||||||||
Returns a string containing a concise, human-readable description of this
object.
| |||||||||||
Handles uncaught exceptions.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Thread.UncaughtExceptionHandler
|
Constructs a new ThreadGroup
with the given name. The new ThreadGroup
will be child of the ThreadGroup
to which the calling thread belongs.
name | the name |
---|
Constructs a new ThreadGroup
with the given name, as a child of the
given ThreadGroup
.
parent | the parent |
---|---|
name | the name |
NullPointerException | if parent == null |
---|---|
IllegalThreadStateException | if parent has been
destroyed already
|
Returns the number of running Thread
s which are children of this thread group,
directly or indirectly.
Returns the number of ThreadGroup
s which are children of this group,
directly or indirectly.
This method is deprecated.
Required deprecated method suspend().
Does nothing. The definition of this method depends on the deprecated
method suspend()
. The exact behavior of this call was never
specified.
b | Used to control low memory implicit suspension |
---|
true
(always)Destroys this thread group and recursively all its subgroups. It is only legal
to destroy a ThreadGroup
that has no threads in it. Any daemon
ThreadGroup
is destroyed automatically when it becomes empty (no threads
or thread groups in it).
IllegalThreadStateException | if this thread group or any of its subgroups has been destroyed already or if it still contains threads. |
---|
Iterates over all active threads in this group (and its sub-groups) and stores the threads in the given array. Returns when the array is full or no more threads remain, whichever happens first.
Note that this method will silently ignore any threads that don't fit in the supplied array.
threads | the array into which the Thread s will be copied |
---|
Thread
s that were copied
Iterates over all thread groups in this group (and, optionally, its sub-groups) and stores the groups in the given array. Returns when the array is full or no more groups remain, whichever happens first.
Note that this method will silently ignore any thread groups that don't fit in the supplied array.
groups | the array into which the ThreadGroup s will be copied |
---|---|
recurse | indicates whether ThreadGroup s in subgroups should be
recursively copied as well or not |
ThreadGroup
s that were copied
Iterates over all active threads in this group (and, optionally, its sub-groups) and stores the threads in the given array. Returns when the array is full or no more threads remain, whichever happens first.
Note that this method will silently ignore any threads that don't fit in the supplied array.
threads | the array into which the Thread s will be copied |
---|---|
recurse | indicates whether Thread s in subgroups should be
recursively copied as well |
Thread
s that were copied
Iterates over all thread groups in this group (and its sub-groups) and and stores the groups in the given array. Returns when the array is full or no more groups remain, whichever happens first.
Note that this method will silently ignore any thread groups that don't fit in the supplied array.
groups | the array into which the ThreadGroup s will be copied |
---|
ThreadGroup
s that were copied
Returns the maximum allowed priority for a Thread
in this thread group.
Returns the name of this thread group.
Returns this thread group's parent ThreadGroup
. It can be null if this
is the the root ThreadGroup.
Interrupts every Thread
in this group and recursively in all its
subgroups.
Checks whether this thread group is a daemon ThreadGroup
.
ThreadGroup
Checks whether this thread group has already been destroyed.
Outputs to System.out
a text representation of the
hierarchy of Thread
s and ThreadGroup
s in this thread group (and recursively).
Proper indentation is used to show the nesting of groups inside groups
and threads inside groups.
Checks whether this thread group is a direct or indirect parent group of a
given ThreadGroup
.
g | the potential child ThreadGroup |
---|
g
Sets whether this is a daemon ThreadGroup
or not. Daemon
thread groups are automatically destroyed when they become empty.
isDaemon | the new value |
---|
Configures the maximum allowed priority for a Thread
in this group and
recursively in all its subgroups.
A caller can never increase the maximum priority of a thread group. Such an attempt will not result in an exception, it will simply leave the thread group with its current maximum priority.
newMax | the new maximum priority to be set |
---|
IllegalArgumentException | if the new priority is greater than Thread.MAX_PRIORITY or less than Thread.MIN_PRIORITY |
---|
This method is deprecated.
Requires deprecated method Thread.stop().
Stops every thread in this group and recursively in all its subgroups.
Returns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
Handles uncaught exceptions. Any uncaught exception in any Thread
is forwarded to the thread's ThreadGroup
by invoking this
method.
New code should use setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler)
instead of thread groups.
t | the Thread that terminated with an uncaught exception |
---|---|
e | the uncaught exception itself |