The documented methods are used by java.lang.Thread to add and remove Threads from their ThreadGroups.
ThreadGroups are containers of Threads and ThreadGroups, therefore providing a tree-like structure to organize Threads. The root ThreadGroup name is "system" and it has no parent ThreadGroup. All other ThreadGroups have exactly one parent ThreadGroup. All Threads belong to exactly one ThreadGroup.
SecurityManager
Public Member Functions | |
ThreadGroup (String name) | |
Constructs a new ThreadGroup with the name provided. | |
ThreadGroup (ThreadGroup parent, String name) | |
Constructs a new ThreadGroup with the name provided, as child of the ThreadGroup parent . | |
int | activeCount () |
Returns the number of Threads which are children of the receiver, directly or indirectly. | |
int | activeGroupCount () |
Returns the number of ThreadGroups which are children of the receiver, directly or indirectly. | |
boolean | allowThreadSuspension (boolean b) |
The definition of this method depends on the deprecated method suspend() . | |
final void | checkAccess () |
If there is a SecurityManager installed, call checkAccess in it passing the receiver as parameter, otherwise do nothing. | |
final void | destroy () |
Destroys the receiver and recursively all its subgroups. | |
int | enumerate (Thread[] threads) |
Copies an array with all Threads which are children of the receiver (directly or indirectly) into the array threads passed as parameters. | |
int | enumerate (Thread[] threads, boolean recurse) |
Copies an array with all Threads which are children of the receiver into the array threads passed as parameter. | |
int | enumerate (ThreadGroup[] groups) |
Copies an array with all ThreadGroups which are children of the receiver (directly or indirectly) into the array groups passed as parameters. | |
int | enumerate (ThreadGroup[] groups, boolean recurse) |
Copies an array with all ThreadGroups which are children of the receiver into the array groups passed as parameter. | |
final int | getMaxPriority () |
Answers the maximum allowed priority for a Thread in the receiver. | |
final String | getName () |
Answers the name of the receiver. | |
final ThreadGroup | getParent () |
Answers the receiver's parent ThreadGroup. | |
final void | interrupt () |
Interrupts every Thread in the receiver and recursively in all its subgroups. | |
final boolean | isDaemon () |
Answers true if the receiver is a daemon ThreadGroup, false otherwise. | |
boolean | isDestroyed () |
Answers true if the receiver has been destroyed already, false otherwise. | |
void | list () |
Outputs to System.out a text representation of the hierarchy of Threads and ThreadGroups in the receiver (and recursively). | |
final boolean | parentOf (ThreadGroup g) |
Answers true if the receiver is a direct or indirect parent group of ThreadGroup g , false otherwise. | |
final void | resume () |
Resumes every Thread in the receiver and recursively in all its subgroups. | |
final void | setDaemon (boolean isDaemon) |
Configures the receiver to be a daemon ThreadGroup or not. | |
final void | setMaxPriority (int newMax) |
Configures the maximum allowed priority for a Thread in the receiver and recursively in all its subgroups. | |
final void | stop () |
Stops every Thread in the receiver and recursively in all its subgroups. | |
final void | suspend () |
Suspends every Thread in the receiver and recursively in all its subgroups. | |
String | toString () |
Answers a string containing a concise, human-readable description of the receiver. | |
void | uncaughtException (Thread t, Throwable e) |
Any uncaught exception in any Thread has to be forwarded (by the VM) to the Thread's ThreadGroup by sending this message (uncaughtException). | |
Package Functions | |
ThreadGroup (ThreadGroup parent) | |
Initialize the "main" ThreadGroup. | |
final void | add (Thread thread) throws IllegalThreadStateException |
Adds a Thread to the receiver. | |
final void | remove (java.lang.Thread thread) |
Removes a Thread from the receiver. | |
Package Attributes | |
ThreadGroup | parent |
int | numThreads |
int | numGroups |
Private Member Functions | |
ThreadGroup () | |
Used by the JVM to create the "system" ThreadGroup. | |
void | add (ThreadGroup g) throws IllegalThreadStateException |
Adds a ThreadGroup to the receiver. | |
void | destroyIfEmptyDaemon () |
int | enumerateGeneric (Object[] enumeration, boolean recurse, int enumerationIndex, boolean enumeratingThreads) |
Copies into enumeration starting at enumerationIndex | |
void | list (int levels) |
void | remove (ThreadGroup g) |
Removes an immediate subgroup from the receiver. | |
void | setParent (ThreadGroup parent) |
Sets the parent ThreadGroup of the receiver, and adds the receiver to the parent's collection of immediate children (if parent is not null ). | |
final boolean | stopHelper () |
final boolean | suspendHelper () |
Private Attributes | |
String | name |
int | maxPriority = Thread.MAX_PRIORITY |
Thread[] | childrenThreads = new Thread[5] |
ThreadGroup[] | childrenGroups = new ThreadGroup[3] |
Object | childrenGroupsLock = new ChildrenGroupsLock() |
Object | childrenThreadsLock = new ChildrenThreadsLock() |
boolean | isDaemon |
boolean | isDestroyed |
Classes | |
class | ChildrenGroupsLock |
class | ChildrenThreadsLock |
java.lang.ThreadGroup.ThreadGroup | ( | ) | [private] |
Used by the JVM to create the "system" ThreadGroup.
Construct a ThreadGroup instance, and assign the name "system".
java.lang.ThreadGroup.ThreadGroup | ( | String | name | ) |
Constructs a new ThreadGroup with the name provided.
The new ThreadGroup will be child of the ThreadGroup to which the Thread.currentThread()
belongs.
name | Name for the ThreadGroup being created |
SecurityException | if checkAccess() for the parent group fails with a SecurityException |
java.lang.ThreadGroup.ThreadGroup | ( | ThreadGroup | parent, | |
String | name | |||
) |
Constructs a new ThreadGroup with the name provided, as child of the ThreadGroup parent
.
parent | Parent ThreadGroup | |
name | Name for the ThreadGroup being created |
NullPointerException | if parent is null | |
SecurityException | if checkAccess() for the parent group fails with a SecurityException | |
IllegalThreadStateException | if parent has been destroyed already |
java.lang.ThreadGroup.ThreadGroup | ( | ThreadGroup | parent | ) | [package] |
Initialize the "main" ThreadGroup.
int java.lang.ThreadGroup.activeCount | ( | ) |
Returns the number of Threads which are children of the receiver, directly or indirectly.
int java.lang.ThreadGroup.activeGroupCount | ( | ) |
Returns the number of ThreadGroups which are children of the receiver, directly or indirectly.
final void java.lang.ThreadGroup.add | ( | Thread | thread | ) | throws IllegalThreadStateException [package] |
Adds a Thread to the receiver.
This should only be visible to class java.lang.Thread, and should only be called when a new Thread is created and initialized by the constructor.
thread | Thread to add to the receiver |
IllegalThreadStateException | if the receiver has been destroyed already |
void java.lang.ThreadGroup.add | ( | ThreadGroup | g | ) | throws IllegalThreadStateException [private] |
Adds a ThreadGroup to the receiver.
g | ThreadGroup to add to the receiver |
IllegalThreadStateException | if the receiver has been destroyed already |
boolean java.lang.ThreadGroup.allowThreadSuspension | ( | boolean | b | ) |
The definition of this method depends on the deprecated method suspend()
.
The behavior of this call was never specified.
b | Used to control low memory implicit suspension |
final void java.lang.ThreadGroup.checkAccess | ( | ) |
If there is a SecurityManager installed, call checkAccess
in it passing the receiver as parameter, otherwise do nothing.
final void java.lang.ThreadGroup.destroy | ( | ) |
Destroys the receiver and recursively all its subgroups.
It is only legal to destroy a ThreadGroup that has no Threads. Any daemon ThreadGroup is destroyed automatically when it becomes empty (no Threads and no ThreadGroups in it).
IllegalThreadStateException | if the receiver or any of its subgroups has been destroyed already | |
SecurityException | if this.checkAccess() fails with a SecurityException |
int java.lang.ThreadGroup.enumerate | ( | Thread[] | threads | ) |
Copies an array with all Threads which are children of the receiver (directly or indirectly) into the array threads
passed as parameters.
If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
threads | Thread array into which the Threads will be copied |
int java.lang.ThreadGroup.enumerate | ( | Thread[] | threads, | |
boolean | recurse | |||
) |
Copies an array with all Threads which are children of the receiver into the array threads
passed as parameter.
Children Threads of subgroups are recursively copied as well if parameter recurse
is true
.
If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
threads | array into which the Threads will be copied | |
recurse | Indicates whether Threads in subgroups should be recursively copied as well or not |
int java.lang.ThreadGroup.enumerate | ( | ThreadGroup[] | groups | ) |
Copies an array with all ThreadGroups which are children of the receiver (directly or indirectly) into the array groups
passed as parameters.
If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
groups | array into which the ThreadGroups will be copied |
int java.lang.ThreadGroup.enumerate | ( | ThreadGroup[] | groups, | |
boolean | recurse | |||
) |
Copies an array with all ThreadGroups which are children of the receiver into the array groups
passed as parameter.
Children ThreadGroups of subgroups are recursively copied as well if parameter recurse
is true
.
If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
groups | array into which the ThreadGroups will be copied | |
recurse | Indicates whether ThreadGroups in subgroups should be recursively copied as well or not |
int java.lang.ThreadGroup.enumerateGeneric | ( | Object[] | enumeration, | |
boolean | recurse, | |||
int | enumerationIndex, | |||
boolean | enumeratingThreads | |||
) | [private] |
Copies into enumeration
starting at enumerationIndex
all Threads or ThreadGroups in the receiver.
If recurse
is true, recursively enumerate the elements in subgroups.
If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
enumeration | array into which the elements will be copied | |
recurse | Indicates whether subgroups should be enumerated or not | |
enumerationIndex | Indicates in which position of the enumeration array we are | |
enumeratingThreads | Indicates whether we are enumerating Threads or ThreadGroups |
final int java.lang.ThreadGroup.getMaxPriority | ( | ) |
Answers the maximum allowed priority for a Thread in the receiver.
int
)final String java.lang.ThreadGroup.getName | ( | ) |
Answers the name of the receiver.
final ThreadGroup java.lang.ThreadGroup.getParent | ( | ) |
Answers the receiver's parent ThreadGroup.
It can be null if the receiver is the the root ThreadGroup.
final void java.lang.ThreadGroup.interrupt | ( | ) |
Interrupts every Thread in the receiver and recursively in all its subgroups.
SecurityException | if this.checkAccess() fails with a SecurityException |
final boolean java.lang.ThreadGroup.isDaemon | ( | ) |
Answers true if the receiver is a daemon ThreadGroup, false otherwise.
boolean java.lang.ThreadGroup.isDestroyed | ( | ) |
Answers true if the receiver has been destroyed already, false otherwise.
void java.lang.ThreadGroup.list | ( | ) |
Outputs to System.out
a text representation of the hierarchy of Threads and ThreadGroups in the receiver (and recursively).
Proper indentation is done to suggest the nesting of groups inside groups and threads inside groups.
final boolean java.lang.ThreadGroup.parentOf | ( | ThreadGroup | g | ) |
Answers true if the receiver is a direct or indirect parent group of ThreadGroup g
, false otherwise.
g | ThreadGroup to test |
final void java.lang.ThreadGroup.remove | ( | java.lang.Thread | thread | ) | [package] |
Removes a Thread from the receiver.
This should only be visible to class java.lang.Thread, and should only be called when a Thread dies.
thread | Thread to remove from the receiver |
void java.lang.ThreadGroup.remove | ( | ThreadGroup | g | ) | [private] |
Removes an immediate subgroup from the receiver.
g | Threadgroup to remove from the receiver |
final void java.lang.ThreadGroup.resume | ( | ) |
Resumes every Thread in the receiver and recursively in all its subgroups.
SecurityException | if this.checkAccess() fails with a SecurityException |
final void java.lang.ThreadGroup.setDaemon | ( | boolean | isDaemon | ) |
Configures the receiver to be a daemon ThreadGroup or not.
Daemon ThreadGroups are automatically destroyed when they become empty.
isDaemon | new value defining if receiver should be daemon or not |
SecurityException | if checkAccess() for the parent group fails with a SecurityException |
final void java.lang.ThreadGroup.setMaxPriority | ( | int | newMax | ) |
Configures the maximum allowed priority for a Thread in the receiver and recursively in all its subgroups.
One can never change the maximum priority of a ThreadGroup to be higher than it was. Such an attempt will not result in an exception, it will simply leave the ThreadGroup with its current maximum priority.
newMax | the new maximum priority to be set |
SecurityException | if checkAccess() fails with a SecurityException | |
IllegalArgumentException | if the new priority is greater than Thread.MAX_PRIORITY or less than Thread.MIN_PRIORITY |
void java.lang.ThreadGroup.setParent | ( | ThreadGroup | parent | ) | [private] |
Sets the parent ThreadGroup of the receiver, and adds the receiver to the parent's collection of immediate children (if parent
is not null
).
parent | The parent ThreadGroup, or null if the receiver is to be the root ThreadGroup |
final void java.lang.ThreadGroup.stop | ( | ) |
Stops every Thread in the receiver and recursively in all its subgroups.
SecurityException | if this.checkAccess() fails with a SecurityException |
ThreadDeath
final boolean java.lang.ThreadGroup.stopHelper | ( | ) | [private] |
final void java.lang.ThreadGroup.suspend | ( | ) |
Suspends every Thread in the receiver and recursively in all its subgroups.
SecurityException | if this.checkAccess() fails with a SecurityException |
final boolean java.lang.ThreadGroup.suspendHelper | ( | ) | [private] |
String java.lang.ThreadGroup.toString | ( | ) |
Answers a string containing a concise, human-readable description of the receiver.
Any uncaught exception in any Thread has to be forwarded (by the VM) to the Thread's ThreadGroup by sending this message (uncaughtException).
This allows users to define custom ThreadGroup classes and custom behavior for when a Thread has an uncaughtException or when it does (ThreadDeath).
t | Thread with an uncaught exception | |
e | The uncaught exception itself |
ThreadDeath
Implements java.lang.Thread.UncaughtExceptionHandler.
Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.
(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.