wood burning stoves 2.0*
The moose likes Threads and Synchronization and the fly likes HOW WOULD I KNOW HOW MANY THREADS ARE RUNNING CURRENTLY?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "HOW WOULD I KNOW HOW MANY THREADS ARE RUNNING CURRENTLY??" Watch "HOW WOULD I KNOW HOW MANY THREADS ARE RUNNING CURRENTLY??" New topic
Author

HOW WOULD I KNOW HOW MANY THREADS ARE RUNNING CURRENTLY??

sanjeev katthi
Greenhorn

Joined: Jun 11, 2007
Posts: 19
HOW WOULD I KNOW HOW MANY THREADS ARE RUNNING CURRENTLY??
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39551
    
  27
Please -PLEASE!-, for all our eyes sake, KeepItDown.


Ping & DNS - updated with new look and Ping home screen widget
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
See JConsole which comes with Java5 and later. It can connect to a running program and show you thread information - and a lot more. You can use the same APIs that it uses if you want that info in your own programs.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Kartik Patel
Ranch Hand

Joined: Sep 12, 2005
Posts: 73
Ideally only one thread should be in running state if its a single processor :-) but if you want to know how many threads (for which start method has been called) are active you can get it by Thread.getActiveCount()


Chop your own wood, and it will warm you twice. - Henry Ford
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I love the ranch because I always see something new. I hadn't read up on activeCount() before. It is for the current thread group only so you may have to walk up the tree of ThreadGroup.getParent to "main" to get all threads.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HOW WOULD I KNOW HOW MANY THREADS ARE RUNNING CURRENTLY??
 
Similar Threads
Running the process even after the program quits!
How many active threads running in the applicationj
Thread.currentthread method on multi cpu
When you run a program how many threads will create ?.
Stoping multiple threads