Java uses Threadgroup to represent thread groups, which are used to classify a batch of threads.
- Java allows the program to control the thread group directly, the control of the thread group is equivalent to control this batch of threads;
- All threads created by the user belong to the specified thread group, and if the program does not explicitly specify which thread group the thread belongs to, the thread belongs to the default thread group;
- By default, a child thread is in the same thread group as the parent thread that created it;
- Once a thread has joined the specified thread group, the thread will always belong to that thread group until the thread dies and the thread cannot change the thread group it belongs to.
A more useful method is defined in Threadgroup: void uncaughtexception (Thread T, Throwable e), which can handle unhandled exceptions thrown in the thread group.
Java Multithreading-Thread groups