2

I have a java application and I want to check on which processor each thread belonging to the app is running. This can be done using top:

top -H -p [pid]

My problem is that on my PC top is showing the thread name whereas on the server it only shows java.

My PC: Centos 6.10 2.6.32-754.12.1.el6.x86_64

Server: Centos 6.9 2.6.32-696.18.7.el6.x86_64

Same top version: 3.2.8

Same java version: "1.8.0_112"

I'm trying to avoid having to do a thread dump and then identifying the thread names.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Mihai
  • 115
  • 1
  • 1
  • 7
  • 1
    Possible duplicate of [How to set name to the thread?](https://stackoverflow.com/q/11457690/608639), [Should threads in Java be named for easier debugging?](https://stackoverflow.com/q/3157852/608639), etc. Also see questions like [How to debug multiple threads/runnables at the same time in Netbeans](https://stackoverflow.com/q/26952986/608639) and [How to Identify threads in Eclipse Debug Perspective?](https://stackoverflow.com/q/5390269/608639). – jww Jun 27 '19 at 15:45
  • @jww I have already looked at those and I can’t find the answer to my issue..? – Mihai Jun 27 '19 at 17:06
  • Show your code. Please provide the source code you use to create the threads in the Java application. – jww Jun 27 '19 at 17:11
  • I can't provide that code unfortunately. But as I said, I am able to see the thread names in top on a different box! – Mihai Jun 28 '19 at 09:30

1 Answers1

0

Use jcmd <PID> Thread.print and pickup the nid (Native Thread Id). (Does involve at least 1 thread dump.)

"Pinpoint-TcpDataExecutor(13-0)" #22 daemon prio=5 os_prio=0 tid=0x00007f14495d1000 nid=0x35 waiting on condition [0x00007f141c6ad000]
   java.lang.Thread.State: TIMED_WAITING (parking)

Then monitor the status of the thread using /proc/<pid>/task/<nid>/status

cat /proc/24/task/53/status
Name:   java
Umask:  0022
State:  S (sleeping)
Tgid:   24
Ngid:   0
Pid:    53
PPid:   1
TracerPid:  0
Uid:    0   0   0   0
Gid:    0   0   0   0
FDSize: 512
maitreyak
  • 269
  • 1
  • 10