Constructs a new thread group. The parent of this new group is the thread group of the currently running thread. <p> The {@code checkAccess} method of the parent thread group is called with no arguments; this may result in a security exception.
Creates a new thread group. The parent of this new group is the specified thread group. <p> The {@code checkAccess} method of the parent thread group is called with no arguments; this may result in a security exception.
Returns an estimate of the number of active threads in this thread group and its subgroups. Recursively iterates over all subgroups in this thread group.
Returns an estimate of the number of active groups in this thread group and its subgroups. Recursively iterates over all subgroups in this thread group.
Adds the specified thread to this thread group.
Increments the count of unstarted threads in the thread group. Unstarted threads are not added to the thread group so that they can be collected if they are never started, but they must be counted so that daemon thread groups with unstarted threads in them are not destroyed.
Determines if the currently running thread has permission to modify this thread group. <p> If there is a security manager, its {@code checkAccess} method is called with this thread group as its argument. This may result in throwing a {@code SecurityException}.
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. <p> First, the {@code checkAccess} method of this thread group is called with no arguments; this may result in a security exception.
Copies into the specified array every active thread in this thread group and its subgroups.
Copies into the specified array every active thread in this thread group. If {@code recurse} is {@code true}, this method recursively enumerates all subgroups of this thread group and references to every active thread in these subgroups are also included. If the array is too short to hold all the threads, the extra threads are silently ignored.
Copies into the specified array references to every active subgroup in this thread group and its subgroups.
Copies into the specified array references to every active subgroup in this thread group. If {@code recurse} is {@code true}, this method recursively enumerates all subgroups of this thread group and references to every active thread group in these subgroups are also included.
Returns the maximum priority of this thread group. Threads that are part of this group cannot have a higher priority than the maximum priority.
Returns the name of this thread group.
Returns the parent of this thread group. <p> First, if the parent is not {@code null}, the {@code checkAccess} method of the parent thread group is called with no arguments; this may result in a security exception.
Interrupts all threads in this thread group. <p> First, the {@code checkAccess} method of this thread group is called with no arguments; this may result in a security exception. <p> This method then calls the {@code interrupt} method on all the threads in this thread group and in all of its subgroups.
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.
Tests if this thread group has been destroyed.
Prints information about this thread group to the standard output. This method is useful only for debugging.
Tests if this thread group is either the thread group argument or one of its ancestor thread groups.
Changes the daemon status of this thread group. <p> First, the {@code checkAccess} method of this thread group is called with no arguments; this may result in a security exception. <p> A daemon thread group is automatically destroyed when its last thread is stopped or its last thread group is destroyed.
Sets the maximum priority of the group. Threads in the thread group that already have a higher priority are not affected. <p> First, the {@code checkAccess} method of this thread group is called with no arguments; this may result in a security exception. <p> If the {@code pri} argument is less than {@link Thread#PRIORITY_MIN} or greater than {@link Thread#PRIORITY_MAX}, the maximum priority of the group remains unchanged. <p> Otherwise, the priority of this ThreadGroupEx object is set to the smaller of the specified {@code pri} and the maximum permitted priority of the parent of this thread group. (If this thread group is the system thread group, which has no parent, then its maximum priority is simply set to {@code pri}.) Then this method is called recursively, with {@code pri} as its argument, for every thread group that belongs to this thread group.
Notifies the group that the thread {@code t} has failed an attempt to start.
Notifies the group that the thread {@code t} has terminated.
Called by the Java Virtual Machine when a thread in this thread group stops because of an uncaught exception, and the thread does not have a specific {@link Thread.UncaughtExceptionHandler} installed. <p> The {@code uncaughtException} method of {@code ThreadGroupEx} does the following: <ul> <li>If this thread group has a parent thread group, the {@code uncaughtException} method of that parent is called with the same two arguments. <li>Otherwise, this method checks to see if there is a {@linkplain Thread#getDefaultUncaughtExceptionHandler default uncaught exception handler} installed, and if so, its {@code uncaughtException} method is called with the same two arguments. <li>Otherwise, this method determines if the {@code Throwable} argument is an instance of {@link ThreadDeath}. If so, nothing special is done. Otherwise, a message containing the thread's name, as returned from the thread's {@link Thread#getName getName} method, and a stack backtrace, using the {@code Throwable}'s {@link Throwable#printStackTrace printStackTrace} method, is printed to the {@linkplain System#err standard error stream}. </ul> <p> Applications can override this method in subclasses of {@code ThreadGroupEx} to provide alternative handling of uncaught exceptions.
Method invoked when the given thread terminates due to the given uncaught exception. <p>Any exception thrown by this method will be ignored by the Java Virtual Machine. @param t the thread @param e the exception
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. <p> 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.
@author unascribed