java.lang.ThreadGroup
java.lang.Object
None
None
JDK 1.0 or later
The ThreadGroup class implements a grouping scheme for threads. A ThreadGroup object can own Thread objects and other ThreadGroup objects. The ThreadGroup class provides methods that allow a ThreadGroup object to control its Thread and ThreadGroup objects as a group. For example, suspend() and resume() methods of a ThreadGroup object call the suspend() and resume() methods of each of the Thread and ThreadGroup objects that belong to the particular ThreadGroup.
When a Java program starts, a ThreadGroup object is created to own the first Thread. Any additional ThreadGroup objects are explicitly created by the program.
public class java.lang.ThreadGroup extends java.lang.Object { // Constructors public ThreadGroup(String name); public ThreadGroup(ThreadGroup parent, String name; // Instance Methods public int activeCount(); public int activeGroupCount(); public boolean allowThreadSuspension(boolean b); // New in 1.1 public final void checkAccess(); public final void destroy(); public int enumerate(Thread list[]); public int enumerate(Thread list[], boolean recurse); public int enumerate(ThreadGroup list[]); public int enumerate(ThreadGroup list[], boolean recurse); public final int getMaxPriority(); public final String getName(); public final ThreadGroup getParent(); public final boolean isDaemon(); public synchronized boolean isDestroyed(); // New in 1.1 public void list(); public final boolean parentOf(ThreadGroup g); public final void resume(); public final void setDaemon(boolean daemon); public final void setMaxPriority(int pri); public final void stop(); public final void suspend(); public String toString(); public void uncaughtException(Thread t, Throwable e); }
The name of this ThreadGroup object.
If the checkAccess() method of the SecurityManager throws a SecurityException.
Creates a ThreadGroup object that has the specified name and the same parent ThreadGroup as the current thread.
The ThreadGroup object that this ThreadGroup object is to be added to.
The name of this ThreadGroup object.
If the checkAccess() method of the SecurityManager throws a SecurityException.
Creates a ThreadGroup object with the specified name and parent ThreadGroup object.
An approximation of the current number of threads in this ThreadGroup object and any child ThreadGroup objects.
This method returns an approximation of the number of threads that belong to this ThreadGroup object and any child ThreadGroup objects. The count is approximate because a thread can die after it is counted, but before the complete count is returned. Also, after a child ThreadGroup is counted but before the total count is returned, additional Thread and ThreadGroup objects can be added to a child ThreadGroup.
An approximation of the current number of child ThreadGroup objects in this ThreadGroup object.
This method returns an approximation of the number of child ThreadGroup objects that belong to this ThreadGroup object. The count is approximate because after a child ThreadGroup is counted but before the total count is returned, additional ThreadGroup objects can be added to a child ThreadGroup.
New as of JDK 1.1
A boolean value that specifies whether or not the run-time system is allowed to suspend threads due to low memory.
The boolean value true.
This method specifies whether or not the Java virtual machine is allowed to suspend threads due to low memory.
If the checkAccess() method of the SecurityManager throws a SecurityException.
This method determines if the currently running thread has permission to modify this ThreadGroup object.
If this ThreadGroup object is not empty, or if it has already been destroyed.
If the checkAccess() method of the SecurityManager throws a SecurityException.
This method destroys this ThreadGroup object and any child ThreadGroup objects. The ThreadGroup must not contain any Thread objects. This method also removes the ThreadGroup object from its parent ThreadGroup object.
The number of Thread objects stored in the array.
This method stores a reference in the array for each of the Thread objects that belongs to this ThreadGroup or any of its child ThreadGroup objects.
If the array is not big enough to contain references to all the Thread objects, only as many references as will fit are put into the array. No indication is given that some Thread objects were left out, so it is a good idea to call activeCount() before calling this method, to get an idea of how large to make the array.
A reference to an array of Thread objects.
A boolean value that specifies whether or not to include Thread objects that belong to child ThreadGroup objects of this ThreadGroup object.
The number of Thread objects stored in the array.
This method stores a reference in the array for each of the Thread objects that belongs to this ThreadGroup object. If recurse is true, the method also stores a reference for each of the Thread objects that belongs to a child ThreadGroup object of this ThreadGroup.
If the array is not big enough to contain references to all the Thread objects, only as many references as will fit are put into the array. No indication is given that some Thread objects were left out, so it is a good idea to call activeCount() before calling this method, to get an idea of how large to make the array.
A reference to an array of ThreadGroup objects.
The number of ThreadGroup objects stored in the array.
This method stores a reference in the array for each ThreadGroup object that belongs to this ThreadGroup or any of its child ThreadGroup objects.
If the array is not big enough to contain references to all the ThreadGroup objects, only as many references as will fit are put into the array. No indication is given that some ThreadGroup objects were left out, so it is a good idea to call activeGroupCount() before calling this method, to get an idea of how large to make the array.
A reference to an array of ThreadGroup objects.
A boolean value that specifies whether or not to include ThreadGroup objects that belong to child ThreadGroup objects of this ThreadGroup object.
The number of ThreadGroup objects stored in the array.
This method stores a reference in the array for each of the ThreadGroup objects that belongs to this ThreadGroup object. If recurse is true, the method also stores a reference for each of the ThreadGroup objects that belongs to a child ThreadGroup object of this ThreadGroup.
If the array is not big enough to contain references to all the ThreadGroup objects, only as many references as will fit are put into the array. No indication is given that some ThreadGroup objects were left out, so it is a good idea to call activeGroupCount() before calling this method, to get an idea of how large to make the array.
The maximum priority that can be assigned to Thread objects that belong to this ThreadGroup object.
This method returns the maximum priority that can be assigned to Thread objects that belong to this ThreadGroup object.
It is possible for a ThreadGroup to contain Thread objects that have higher priorities than this maximum, if they were given that higher priority before the maximum was set to a lower value.
The name of this ThreadGroup object.
This method returns the name of this ThreadGroup object.
The parent ThreadGroup object of this ThreadGroup, or null if this ThreadGroup is the root of the thread group hierarchy.
This method returns the parent ThreadGroup object of this ThreadGroup object. If this ThreadGroup is at the root of the thread group hierarchy and has no parent, the method returns null.
true if this ThreadGroup is a daemon thread group; otherwise false.
This method determines whether or not this ThreadGroup is a daemon thread group, based on the value of daemon attribute of this ThreadGroup object. A daemon thread group is destroyed when the last Thread in it is stopped, or the last ThreadGroup in it is destroyed.
New as of JDK 1.1
true if this ThreadGroup has been destroyed; otherwise false.
This method determines whether or not this ThreadGroup has been destroyed.
This method outputs a listing of the contents of this ThreadGroup object to System.out.
A ThreadGroup object.
true if this ThreadGroup object is the same ThreadGroup, or a direct or indirect parent of the specified ThreadGroup; otherwise false.
This method determines if this ThreadGroup object is the same as the specified ThreadGroup or one of its ancestors in the thread-group hierarchy.
If the checkAccess() method of the SecurityManager throws a SecurityException.
This method resumes each Thread object that directly or indirectly belongs to this ThreadGroup object by calling its resume() method.
The new value for this ThreadGroup object's daemon attribute.
If the checkAccess() method of the SecurityManager throws a SecurityException.
This method sets the daemon attribute of this ThreadGroup object to the given value. A daemon thread group is destroyed when the last Thread in it is stopped, or the last ThreadGroup in it is destroyed.
The new maximum priority for Thread objects that belong to this ThreadGroup object.
This method sets the maximum priority that can be assigned to Thread objects that belong to this ThreadGroup object.
It is possible for a ThreadGroup to contain Thread objects that have higher priorities than this maximum, if they were given that higher priority before the maximum was set to a lower value.
If the checkAccess() method of the SecurityManager throws a SecurityException.
This method stops each Thread object that directly or indirectly belongs to this ThreadGroup object by calling its stop() method.
If the checkAccess() method of the SecurityManager throws a SecurityException.
This method suspends each Thread object that directly or indirectly belongs to this ThreadGroup object by calling its suspend() method.
A string representation of this ThreadGroup object.
Object.toString()
This method returns a string representation of this ThreadGroup object.
A reference to a Thread that just died because of an uncaught exception.
The uncaught exception.
This method is called when a Thread object that belongs to this ThreadGroup object dies because of an uncaught exception. If this ThreadGroup object has a parent ThreadGroup object, this method just calls the parent's uncaughtException() method. Otherwise, this method must determine whether the uncaught exception is an instance of ThreadDeath. If it is, nothing is done. If it is not, the method calls the printStackTrace() method of the exception object.
If this method is overridden, the overriding method should end with a call to super.uncaughtException().
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
IllegalThreadStateException, Object, Runnable, SecurityException, SecurityManager, Thread, Throwable