3. Thread Group

Every Java thread is a member of a thread group.

Default Group: The same as the thread that created it.

Start up Group: the Java runtime system creates a ThreadGroup named "main".

The ThreadGroup class manages groups of threads for Java applications.

Figure 7.2. ThreadGroup Class

ThreadGroup Class

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 on all the threads and subgroups within the ThreadGroup;

  • resume();

  • stop();

  • suspend():

  • Access Restriction Methods - ThreadGroup and Thread allow the security manager to restrict access to threads based on group membership.

Audio in Portuguese