When a task requires more than one child thread to handle the business, it is not desirable that these sub-threads be disorganized, and the thread groups are created when they need to be managed uniformly.
Threadgroup API description, where red is the common method
| Method Summary |
int |
activeCount() Returns the estimated number of active threads in this thread group. |
int |
activeGroupCount() Returns the estimated number of active thread groups in this thread group. |
boolean |
allowThreadSuspension(boolean b) is obsolete. The definition of this call depends on suspend (), which is deprecated. Further, the behavior of this call is never specified. |
void |
checkAccess() Determines whether the currently running thread has permission to modify this thread group. |
void |
destroy() Destroys this thread group and all its child groups. |
int |
enumerate(Thread[] list) Copies all active threads in this thread group and its subgroups into the specified array. |
int |
enumerate(Thread[] list, boolean recurse) Copies all the active threads in this thread group into the specified array. |
int |
enumerate(ThreadGroup[] list) Copies a reference to all active subgroups in this thread group into the specified array. |
int |
enumerate(ThreadGroup[] list, boolean recurse) Copies a reference to all active subgroups in this thread group into the specified array. |
int |
getMaxPriority() Returns the highest priority for this thread group. |
String |
getName() Returns the name of this thread group. |
ThreadGroup |
getParent() Returns the parent thread group for this thread group. |
void |
interrupt() Interrupts all threads in this thread group. |
boolean |
isDaemon() Tests whether this thread group is a background program thread group. |
boolean |
isDestroyed() Tests whether this thread group has been destroyed. |
void |
list() Prints information about this thread group to standard output. |
boolean |
parentOf(ThreadGroup g) Tests whether this thread group is a thread group parameter or one of its ancestor thread groups. |
void |
resume() is obsolete. This method is only used for federated Thread.Suspend and threadgroup.suspend , because they are inherently prone to deadlocks, so both are deprecated. For more information, see Thread.Suspend (). |
void |
setDaemon(boolean daemon) Change the background program state for this thread group. |
void |
setMaxPriority(int pri) Sets the highest priority for the thread group. |
void |
stop() is obsolete. This method has inherent insecurity. For more information, see Thread.stop (). |
void |
suspend() is obsolete. This method easily leads to deadlocks. For more information, see Thread.Suspend (). |
String |
toString() Returns a string representation of this thread group. |
void |
uncaughtException(Thread t, Throwable e) This method is called by Java Virtual Machine when a thread in this thread group stops because of an uncaught exception and the thread does not have a specific thread.uncaughtexceptionhandler installed. |
2,threadgroup Concepts and usage