The
ThreadGroup
class manages groups of threads for Java applications. A ThreadGroup
can contain any number of threads. The threads in a group are generally related in some way, such as who created them, what function they perform, or when they should be started and stopped. ThreadGroup
s can contain not only threads but also other ThreadGroup
s. The top-most thread group in a Java application is the thread group named main
. You can create threads and thread groups in the main
group. You can also create threads and thread groups in subgroups of main
. The result is a root-like hierarchy of threads and thread groups:
The ThreadGroup
class has methods that can be categorized as follows:
- Collection Management Methods--Methods that manage the collection of threads and subgroups contained in the thread group.
- Methods That Operate on the Group--These methods set or get attributes of the
ThreadGroup
object. - Methods That Operate on All Threads within a Group--This is a set of methods that perform some operation, such as start or resume, on all the threads and subgroups within the
ThreadGroup
. - Access Restriction Methods--
ThreadGroup
andThread
allow the security manager to restrict access to threads based on group membership.
No comments:
Post a Comment