TOP command: Find the Java thread with the highest CPU usage

Source: Internet
Author: User

Reference http://lxiaodao.iteye.com/blog/1413774

And long source

28147 is the Java Process number. It is found through the JPS command.

top -Hp 28174 -d 1 -n 1  

Find the thread that occupies the highest CPU

 PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                          20765 admin     22   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20766 admin     18   0 1628m 1.3g  15m S  0.0 17.5   0:00.62 java                                                                             20767 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:27.16 java                                                                             20768 admin     16   0 1628m 1.3g  15m S  0.0 17.5   0:27.40 java                                                                             20769 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:27.77 java                                                                             20770 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:27.52 java                                                                             20771 admin     16   0 1628m 1.3g  15m S  0.0 17.5   0:27.63 java                                                                             20772 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:15.18 java                                                                             20773 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20774 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20775 admin     19   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20776 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:11.21 java                                                                             20777 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:09.81 java                                                                             20778 admin     25   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20779 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20783 admin     15   0 1628m 1.3g  15m S  0.0 17.5   0:00.03 java                                                                             20784 admin     19   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20785 admin     20   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java                                                                             20786 admin     21   0 1628m 1.3g  15m S  0.0 17.5   0:00.00 java 

20766 is the most CPU-consuming thread. It is converted into a hex worker E, and then run the jstack command to view the thread stack.

[admin@v022067 ~/logs]$ jstack -l 20765 | grep 511e -A 20     "DestroyJavaVM" prio=10 tid=0x00002aaab4268800 nid=0x511e waiting on condition [0x0000000000000000]   java.lang.Thread.State: RUNNABLE   Locked ownable synchronizers:        - None"pool-3-thread-1" prio=10 tid=0x00002aaab4344000 nid=0x5138 waiting on condition [0x00000000428ad000]   java.lang.Thread.State: WAITING (parking)        at sun.misc.Unsafe.park(Native Method)        - parking to wait for  <0x00000000c01259f0> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:156)        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:1987)        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:399)        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:947)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)        at java.lang.Thread.run(Thread.java:662)   Locked ownable synchronizers:        - None"main-EventThread" daemon prio=10 tid=0x0000000043bce800 nid=0x5137 waiting on condition [0x00000000427ac000]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.