Summary

Here are the methods of the ThreadGroup class that we introduced in this chapter:

ThreadGroup(String name)

Creates a thread group with the given name.

ThreadGroup(ThreadGroup parent, String name)

Creates a thread group that descends from the given parent and has the given name.

void suspend() (deprecated in Java 2)

Suspends all threads that descend from this thread group.

void resume() (deprecated in Java 2)

Resumes all threads that descend from this thread group.

void stop() (deprecated in Java 2)

Stops all threads that descend from this thread group.

void destroy()

Cleans up the thread group and removes it from the thread group hierarchy.

void interrupt() ( Java 2 and above only)

Interrupts all threads that descend from this thread group.

ThreadGroup getParent()

Returns the ThreadGroup reference of the parent of a thread group.

boolean parentOf(ThreadGroup g)

Returns true if the group g is an ancestor of a thread group.

int enumerate(Thread list[])

Fills in the list array with a reference to all threads in this thread group and all threads that are in groups that descend from this thread group.

int enumerate(Thread list[], boolean recurse)

Fills in the list array with a reference to all threads in this thread group and, if recurse is true, all threads that are in groups that descend from this thread group.

int activeCount()

Returns the number of active threads in this and all descending thread groups.

int enumerate(ThreadGroup list[])

Retrieves all thread group references ...

Get Java Threads, 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.