Obtaining the Number of Running Threads

You saw in the ThreadGroup class that the method activeCount returned an estimate of the number of threads running within that ThreadGroup. The Thread class itself also has a method called activeCount. It is a static method that returns the number of threads that are running within the thread's ThreadGroup. Using this method, you don't have to get the ThreadGroup for the thread and ask it.

Get Special Edition Using Java 2 Standard 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.