Java Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 6.00

"ThreadGroup" Class - Container of Threads and Thread Groups

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.

Table of Contents

 About This Book

 Installing JDK 1.4 on Windows 2000

 Installing JDK 1.5 on Windows XP

 Installing JDK 1.6 on Windows XP

 Execution Process, Entry Point, Input and Output

 Bits, Bytes, Bitwise and Shift Operations

 Managing Bit Strings in Byte Arrays

 StringBuffer - The String Buffer Class

 System Properties and Runtime Object Methods

 Execution Threads and Multi-Threading Java Programs

ThreadGroup Class and "system" ThreadGroup Tree

"ThreadGroup" Class - Container of Threads and Thread Groups

 Displaying the "system" ThreadGroup Tree

 Adding Threads and Thread Groups

 JDK 1.3 Bug - Memory Leak With Unstarted Threads

 Synchronization Technique and Synchronized Code Blocks

 Deadlock Condition Example Programs

 Garbage Collection and the gc() Method

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2008
"ThreadGroup" Class - Container of Threads and Thread Groups