dcsimg
How to get all the threads in a JVM?
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Vincent_Hao
Posted On:   Wednesday, November 27, 2002 07:04 PM

We can know which and how many processes is running in windows via Task Manager. And is there any way that we can know which and how many threads is running in a JVM?

thank you.

Re: How to get all the threads in a JVM?

Posted By:   Muruganantham_Mani  
Posted On:   Thursday, December 26, 2002 02:32 AM

Hai,


The following code will get you all the running threads of a JVM.



Regards

Muruga




public Thread[] getAllRunningThreads()
{
ThreadGroup group = Thread.currentThread().getThreadGroup();
ThreadGroup temp = group;

while (group != null)
{
temp = group;
group = group.getParent();
}

int estimatedSize = temp.activeCount() * 2;
Thread[] list = new Thread[estimatedSize];

int actualSize = temp.enumerate(list);
Thread[] actualList = new Thread[actualSize];

System.arraycopy(list, 0, actualList, 0, actualSize);

return actualList;
}

Re: How to get all the threads in a JVM?

Posted By:   Gautam_Marwaha  
Posted On:   Thursday, November 28, 2002 01:52 AM

Make the java console active and press Ctrl+Pause/Break - this would show the thread dump (info on threads running for the java process)
About | Sitemap | Contact