The ThreadGroup class in Java, part of the java.lang package, represents a group of threads. It provides methods for managing threads and thread groups as a single unit. This can be particularly useful for handling a collection of threads in a hierarchical manner.
Java ThreadGroup Methods
The table below contains various methods of the Java ThreadGroup class, each with a link to a detailed explanation, examples, and real-world uses. Click on the method names to learn more about how to use them effectively in your applications.
| Method | Description |
|---|---|
| activeCount() | Returns an estimate of the number of active threads in this thread group and its subgroups. |
| activeGroupCount() | Returns an estimate of the number of active groups in this thread group. |
| enumerate() | Copies into the specified array every active thread in this thread group and its subgroups. |
| getMaxPriority() | Returns the maximum priority of this thread group. |
| getName() | Returns the name of this thread group. |
| getParent() | Returns the parent of this thread group. |
| interrupt() | Interrupts all threads in this thread group. |
| list() | Prints information about this thread group to the standard output. |
The ThreadGroup class provides a robust feature for managing a group of threads, allowing you to manipulate threads as a group rather than individually.
For more detailed information, please refer to the official Java SE Documentation.