A thread group represents a set of threads. In addition, a thread
group can also include other thread groups. The thread groups form
a tree in which every thread group except the initial thread group
has a parent.
A thread is allowed to access information about its own thread
group, but not to access information about its thread group's
parent thread group or any other thread groups.
Tests if this thread group is a daemon thread group. A
daemon thread group is automatically destroyed when its last
thread is stopped or its last thread group is destroyed.
Returns:
true if this thread group is a daemon thread group;
false otherwise.
isDestroyed
public synchronized boolean isDestroyed()
Tests if this thread group has been destroyed.
setDaemon
public final void setDaemon(boolean daemon)
Changes the daemon status of this thread group.
First, the checkAccess method of this thread group is
called with no arguments; this may result in a security exception.
A daemon thread group is automatically destroyed when its last
thread is stopped or its last thread group is destroyed.
Parameters:
daemon - if true, marks this thread group as
a daemon thread group; otherwise, marks this
thread group as normal.
Determines if the currently running thread has permission to
modify this thread group.
If there is a security manager, its checkAccess method
is called with this thread group as its argument. This may result
in throwing a SecurityException.
Copies into the specified array every active thread in this
thread group and its subgroups.
An application should use the activeCount method to
get an estimate of how big the array should be. If the array is
too short to hold all the threads, the extra threads are silently
ignored.
Parameters:
list - an array into which to place the list of threads.
enumerate
public int enumerate(Thread list[],
boolean recurse)
Copies into the specified array every active thread in this
thread group. If the recurse flag is
true, references to every active thread in this
thread's subgroups are also included. If the array is too short to
hold all the threads, the extra threads are silently ignored.
An application should use the activeCount method to
get an estimate of how big the array should be.
Parameters:
list - an array into which to place the list of threads.
recurse - a flag indicating whether also to include threads
in thread groups that are subgroups of this
thread group.
Copies into the specified array references to every active
subgroup in this thread group.
An application should use the activeGroupCount
method to get an estimate of how big the array should be. If the
array is too short to hold all the thread groups, the extra thread
groups are silently ignored.
Parameters:
list - an array into which to place the list of thread groups.
Copies into the specified array references to every active
subgroup in this thread group. If the recurse flag is
true, references to all active subgroups of the
subgroups and so forth are also included.
An application should use the activeGroupCount
method to get an estimate of how big the array should be.
Parameters:
list - an array into which to place the list of threads.
recurse - a flag indicating whether to recursively enumerate
all included thread groups.
Destroys this thread group and all of its subgroups. This thread
group must be empty, indicating that all threads that had been in
this thread group have since stopped.
Called by the Java Virtual Machine when a thread in this
thread group stops because of an uncaught exception.
The uncaughtException method of
ThreadGroup does the following:
If this thread group has a parent thread group, the
uncaughtException method of that parent is called
with the same two arguments.
Otherwise, this method determines if the Throwable
argument is an instance of ThreadDeath. If so, nothing
special is done. Otherwise, the Throwable's
printStackTrace method is called to print a stack
backtrace to the standard error stream.
Applications can override this method in subclasses of
ThreadGroup to provide alternative handling of
uncaught exceptions.