This section describes the 'ThreadGroup' class and its main methods. A 'ThreadGroup' object is a container of threads and thread groups.
ThreadGroup: A class represents a collection of Thread objects and ThreadGroup objects.
Features of the ThreadGroup class:
All objects of ThreadGroup class are organized as a tree structure.
Each ThreadGroup object must have a parent ThreadGroup object in the tree,
except the root object.
The root object of the ThreadGroup tree is provided and managed by
the Java Virtual Machine (JVM).
Main methods:
getParent(): Returns the parent ThreadGroup object.
activeCount(): Returns the number of active Thread objects in this
ThreadGroup object and its sub-tree.
activeGroupCount(): Returns the number of active ThreadGroup objects in
this ThreadGroup object and its sub-tree.
enumerate(Thread[] l): Copies active Thread objects in this ThreadGroup
object and its sub-tree.
enumerate(ThreadGroup[] l): Copies active ThreadGroup objects in this
ThreadGroup object and its sub-tree.
interrupt(): Calls Thread.interrupt() method on
all Thread objects in this ThreadGroup object and its sub-tree.