Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inspecting Java threads in Linux using top

I am inspecting a Java process in Linux using

top -H 

However, I cannot read the name of the thread in the "COMMAND" column (because it is too long). If I use 'c' to expand the full name of the process, then it is still to long to fit.

How can I obtain the full name of the command?

like image 849
Jake Avatar asked Jan 21 '11 21:01

Jake


People also ask

How do you show threads in top command?

The top command can show a real-time view of individual threads. To enable thread views in the top output, invoke top with "-H" option. This will list all Linux threads. You can also toggle on or off thread view mode while top is running, by pressing 'H' key.

How do I identify high CPU utilization by Java threads on Linux?

Press Shift + h and wait a few seconds. You can see the Show threads on message in the top console. Now, you can see thread-level details like CPU and memory utilization. You'll notice that a java command thread with PID 7087 is utilizing 94% of the CPU.

How do I monitor JVM threads?

The simplest way to see the number of threads in Java is to use a graphical tool like Java VisualVM. Apart from the application threads, Java VisualVM also lists the GC or any other threads used by the application like JMX threads. Monitoring the number of threads is the most basic feature in Java VisualVM.

How do you check how many threads are there in Linux?

How to Retrieve Maximum Thread Count. The kernel parameter threads-max controls the maximum number of threads. This parameter is defined in the file /proc/sys/kernel/threads-max. Here, the output 63704 indicates that the kernel can execute a maximum of 63,704 threads.


1 Answers

You can inspect java threads with the tool jstack. It will list the names, stacktraces and other useful information of all threads belonging to the specified process pid.

Edit: The parameter nid in the thread dump of jstack is the hex version of the LWP that is displayed by top in the pid column for threads.

like image 196
Hendrik Brummermann Avatar answered Sep 22 '22 04:09

Hendrik Brummermann