16.6. Thread Groups

The ThreadGroup class provides a convenient mechanism for controlling sets of threads. A ThreadGroup can contain other thread groups in addition to threads, letting you arrange groups hierarchically. The constructors and methods for the ThreadGroup class are summarized in the following subsections.

Constructors

public ThreadGroup(String groupName)

This constructor creates a named ThreadGroup that belongs to the same group as the thread that called the constructor.

public ThreadGroup(ThreadGroup parent, String groupName)

This constructor creates a named ThreadGroup that belongs to the specified parent group.

Methods

public synchronized int activeCount()

This method gives the number of active threads directly or indirectly in ...

Get Core Web Programming, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.