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 = null |
int | numThreads = 0 |
int | numGroups = 0 |
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 Object() |
Object | childrenThreadsLock = new Object() |
boolean | isDaemon = false |
boolean | isDestroyed = false |
long | memorySpace |
|
Used by the JVM to create the "system" ThreadGroup. Construct a ThreadGroup instance, and assign the name "system". |
|
Constructs a new ThreadGroup with the name provided.
The new ThreadGroup will be child of the ThreadGroup to which the
|
|
Constructs a new ThreadGroup with the name provided, as child of the ThreadGroup
|
|
Initialize the "main" ThreadGroup.
|
|
Returns the number of Threads which are children of the receiver, directly or indirectly.
|
|
Returns the number of ThreadGroups which are children of the receiver, directly or indirectly.
|
|
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.
|
|
Adds a ThreadGroup to the receiver.
|
|
The definition of this method depends on the deprecated method The behavior of this call was never specified.
|
|
If there is a SecurityManager installed, call
|
|
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).
|
|
Copies an array with all Threads which are children of the receiver (directly or indirectly) into the array If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
|
|
Copies an array with all Threads which are children of the receiver into the array
Children Threads of subgroups are recursively copied as well if parameter If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
|
|
Copies an array with all ThreadGroups which are children of the receiver (directly or indirectly) into the array If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
|
|
Copies an array with all ThreadGroups which are children of the receiver into the array
Children ThreadGroups of subgroups are recursively copied as well if parameter If the array passed as parameter is too small no exception is thrown - the extra elements are simply not copied.
|
|
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.
recurseCollection should be enumerated or not
|
|
Answers the maximum allowed priority for a Thread in the receiver.
|
|
Answers the name of the receiver.
|
|
Answers the receiver's parent ThreadGroup. It can be null if the receiver is the the root ThreadGroup.
|
|
Interrupts every Thread in the receiver and recursively in all its subgroups.
|
|
Answers true if the receiver is a daemon ThreadGroup, false otherwise.
|
|
Answers true if the receiver has been destroyed already, false otherwise.
|
|
Outputs to Proper identation is done to suggest the nesting of groups inside groups and threads inside groups. |
|
Answers true if the receiver is a direct or indirect parent group of ThreadGroup
|
|
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.
|
|
Removes an immediate subgroup from the receiver.
|
|
Resumes every Thread in the receiver and recursively in all its subgroups.
|
|
Configures the receiver to be a daemon ThreadGroup or not. Daemon ThreadGroups are automatically destroyed when they become empty.
|
|
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.
|
|
Sets the parent ThreadGroup of the receiver, and adds the receiver to the parent's collection of immediate children (if
|
|
Stops every Thread in the receiver and recursively in all its subgroups.
|
|
|
|
Suspends every Thread in the receiver and recursively in all its subgroups.
|
|
|
|
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).
|