File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Threads and Synchronization and the fly likes ThreadGroup .activeCount() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "ThreadGroup .activeCount()" Watch "ThreadGroup .activeCount()" New topic

ThreadGroup .activeCount()

Anthony Smith
Ranch Hand

Joined: Sep 10, 2001
Posts: 285
I have a simple jsp page that has the following info on it:
(removed the html and jsp tags)

Runtime rt = Runtime.getRuntime();
// forcibly suggest garbage collection

// get the primordial threadgroup
ThreadGroup tg = Thread.currentThread().getThreadGroup();
while (tg.getParent()!=null) { tg=tg.getParent(); }


Why does the value of tg.activeCount() get larger every time this page is called? Better yet, why does the value of tg.activeCount() never get smaller?
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Hi Anthony, I don�t know the answer to your question, but I have a suggestion. ThreadGroup.enumerate will give you a list of the active threads.
I agree. Here's the link:
subject: ThreadGroup .activeCount()
Similar Threads
Thread Null pointer problem
what's running on my VM?
java threads
activeCount Gives worng number :argh:
status of deamon threads