Monday, 11 October 2010

Which Java Thread is using CPU on Linux?

More for my own reference than anything else, a means to establish which java thread is using CPU time on Linux.

  1. Get the process ID (PID) using ps -ef
  2. Enter the command
    top -p<pid>
  3. Press shift-h
  4. All threads in the parent java process should start to appear with their lightweight process IDs and CPU usage - this takes some time
  5. Now send a
    kill -3 <pid>
    to the process - this will trigger a thread dump without ending the process.
    will also work if you have java running in a console.
  6. Convert the PIDs of the lightweight process you are interested in into hex (so 2042 = 0x7FA)
  7. Find the file where the Java process was sending system.out and grep for
    nid=<lightweight pid in hex>
Bingo, you should have the thread name and stack of the thread using up CPU time


  1. Need help with java. is the company that you need. They have finished a dozens of web, mobile projects. Also they good in search engine optimisation. So to no go far away you should go to specialist and your business will go up.

  2. This comment has been removed by the author.

  3. Hi, I'd like to recommend you this company if you have questions about professional software and game testing. I'm working with them for quite a long time.

  4. And since most people wouldn't know the difference between a PC built with an Intel chip or AMD chip, many systems were built using AMD chips. DDR4 VS DDR3 RAM: Know The differences