Linux thread error lookup, with threading Analysis command

Source: Internet
Author: User

One

using top and Jstack to find thread errors

We use the jstack from the JDK to analyze it. When Linux CPU is consumed by Java programs, the following process might help you:

1.top Find out which process consumes a high CPU
21125 co_ad2 0 1817m 776m 9712S 3.3 4.9 12:03.24java
5284co_ad 0 3028m 2.5g 9432S 1.0 16.3 6629:44java
21994mysql 0 449m 88m 5072 S 1.0 0.6 67582:38mysqld
8657 Co_sparr 0 2678m 892m 9220S 0.3 5.7 103:06.13 Java

Here we analyze 21125 of this Java process.

2.top shift+h Find out which thread consumes a high CPU
First enter top, then press Shift+h
21233 co_ad2 0 1807m 630m 9492S 1.3 4.0 0:05.12java
20503 co_ad2_s 0 1360m 560m 9176S 0.3 3.6 0:46.72java
21134 co_ad2 0 1807m 630m 9492S 0.3 4.0 0:00.72java
22673 co_ad2 0 1807m 630m 9492S 0.3 4.0 0:03.12 Java

Here we analyze 21233 of this thread, and note that this thread is part of the 21125 process.

3.jstack find information for this thread
Jstack [Process]|grep-a 10 [thread 16]
That

Java code
    1. Jstack 21125|grep-a 52F1


-A 10 means finding the following 10 rows of the row. 21233 Convert the calculator to 16 binary 52f1, note that the letter is lowercase.
Results:

Java code
    1. "http-8081-11" daemon prio=10 tid=0x00002aab049a1800 NID=0X52BB in object.wait () [0x0000000042c75000]
    2. Java.lang.Thread.State:WAITING (on object monitor)
    3. At java.lang.Object.wait (Native Method)
    4. At Java.lang.Object.wait (object.java:485)
    5. At Org.apache.tomcat.util.net.jioendpoint$worker.await (jioendpoint.java:416)


You might be able to locate the offending code at once.

Two

Jstack (view threads), Jmap (view memory), and Jstat (profiling) commands

Specific view: http://guafei.iteye.com/blog/1815222

Linux thread error lookup, with threading Analysis command

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.