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 OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: ThreadGroup .activeCount()