Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Utility to view threads in a Java process

I've got a java application on a windows machine which pins the CPU from time to time. Would like to run a utility to get an idea of how many threads etc that application is creating. Is there such a utility?

like image 407
Jeremy Avatar asked Jul 10 '09 16:07

Jeremy


People also ask

How can I see the process threads?

To enable thread views in htop, launch htop, and press <F2> to enter htop setup menu. Choose "Display option" under "Setup" column, and toggle on "Three view" and "Show custom thread names" options. Presss <F10> to exit the setup. Now you will see the follow threaded view of individual processes.

How do you read a thread in Java?

A thread in Java is the direction or path that is taken while a program is being executed. Generally, all the programs have at least one thread, known as the main thread, that is provided by the JVM or Java Virtual Machine at the starting of the program's execution.

How do you get threads in a program?

Using getAllStackTrace() Method The getAllStackTrace() method gives a stack trace of all the running threads. Then we make a set of the keys of that element because the method returns a map, and then we loop over all the elements of the set to print all the running threads.

How do you find the thread count in Java?

The java. lang. Thread. activeCount() method returns the number of active threads in the current thread's thread group.


2 Answers

jconsole is included with the jdk and includes thread/memory/cpu monitoring

like image 144
Clint Avatar answered Oct 12 '22 23:10

Clint


You could try jstack, should be part of the jdk.

like image 37
mattwright Avatar answered Oct 13 '22 00:10

mattwright