`
can_do
  • 浏览: 263954 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Java thread dump的分析思路

阅读更多
Java thread dump的分析思路:
第一步:java thread dump中首先需要检查是否有死锁,即deadlock,通过jstack生成的dump,
会自动将deadlock列出来;如果有deadlock,需要查看引起死锁的代码;

第二步:检查是否有条件等待状态的线程【wait on condition】,如果有,需要检查对应代码的业务逻辑是否合理!

第三步:其次要检查是否大量线程发生block,一般blocked thread的状态有【waiting for monitor entry】和【in Object.wait()】
前者是在Entry Set队列中,【in Object.wait()】是在Wait Set队列中。

第四步:检查是否发生热锁,发生热锁的必要条件是:
(1)、cpu繁忙并且系统态远大于用户态
(2)、cpu数目越多,性能反而越差,可以通过taskset指定引用哪些cpu核。
如果发生热锁,需要定位到代码段,分析其代码逻辑并进行改进。


注意:1、在分析thread dump时,要比对至少三次的thread dump,而不要拿某一个dump来说事,因为thread dump是某个时刻的快照
,需要横向比对定位问题。2、NIO比BIO在多线程处理上更好一些。3、代码中尽量少用synchronized关键字,除非你对多线程管理的很好。

一般线程的状态有以下几种:
************************
1.线程状态:【runnable】
"Running HTTPHandler-995" prio=10 tid=0x2eff0800 nid=0x108a runnable [0x7c75e000]
   java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:146)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
- locked <0x50724c18> (a java.io.BufferedInputStream)
at com.cnd.web.http.tcp.TCP_BIOProtocol.readLine(Unknown Source)
at com.cnd.web.http.tcp.TCP_BIOProtocol.readRequestLine(Unknown Source)
at com.cnd.web.http.tcp.TCP_BIOProtocol.read(Unknown Source)
at com.cnd.web.http.tcp.TCP_BIOConnection.getNextRequest(Unknown Source)
at com.cnd.web.http.ConnectionHandler.processConnection(Unknown Source)
at com.cnd.web.http.ConnectionHandler.run(Unknown Source)
at com.cnd.util.ThreadPoolImpl$WorkerThread.run(Unknown Source)
************************
2.线程状态:【wait on condition】

*************************
3.线程状态:【waiting for monitor entry】
"Running ORBWorker-299" prio=10 tid=0x2ea82400 nid=0x10a3 waiting for monitor entry [0x7cc2c000]
   java.lang.Thread.State: BLOCKED (on object monitor)
at com.cnd.corba.ee.impl.orb.ORBImpl.create_any(Unknown Source)
- locked <0x4632e838> (a com.cnd.corba.ee.impl.orb.ORBImpl)
at com.cnd.corba.ee.impl.javax.rmi.CORBA.Util.writeAny(Unknown Source)
at com.cnd.corba.rmi.Util.writeAny(Unknown Source)
at javax.rmi.CORBA.Util.writeAny(Util.java:96)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.writeObjectField(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.writeField(Unknown Source)
at com.cnd.corba.ee.impl.io.OutputStreamHook$HookPutFields.write(Unknown Source)
at com.cnd.corba.ee.impl.io.OutputStreamHook.writeFields(Unknown Source)
at java.beans.PropertyChangeSupport.writeObject(PropertyChangeSupport.java:418)
at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.invokeObjectWriter(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputObject(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValue(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream.write_value(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.writeObjectField(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputClassFields(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputObject(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValue(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_abstract_interface(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream.write_abstract_interface(Unknown Source)
at com.cnd.corba.ee.impl.javax.rmi.CORBA.Util.writeAbstractObject(Unknown Source)
at com.cnd.corba.rmi.Util.writeAbstractObject(Unknown Source)
at javax.rmi.CORBA.Util.writeAbstractObject(Util.java:147)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.writeObjectOverride(Unknown Source)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:339)
at java.util.ArrayList.writeObject(ArrayList.java:673)
at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.invokeObjectWriter(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputObject(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValue(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream.write_value(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.writeObjectField(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputClassFields(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputObject(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValue(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream.write_value(Unknown Source)
at com.cnd.corba.ee.impl.corba.TCUtility.marshalIn(Unknown Source)
at com.cnd.corba.ee.impl.corba.AnyImpl.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_any(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream.write_any(Unknown Source)
at com.cnd.corba.ee.impl.javax.rmi.CORBA.Util.writeAny(Unknown Source)
at com.cnd.corba.rmi.Util.writeAny(Unknown Source)
at javax.rmi.CORBA.Util.writeAny(Util.java:96)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.writeObjectField(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputClassFields(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.defaultWriteObjectDelegate(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.outputObject(Unknown Source)
at com.cnd.corba.ee.impl.io.IIOPOutputStream.simpleWriteObject(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueInternal(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValueWithVersion(Unknown Source)
at com.cnd.corba.ee.impl.io.ValueHandlerImpl.writeValue(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.writeRMIIIOPValueType(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream_1_0.write_value(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputStream.write_value(Unknown Source)
at com.cssnet.platform.baseframe.core.facade._DomainFacadeBean_ObjectImpl_2_Tie._invoke(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(Unknown Source)
at com.cnd.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
at com.cnd.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(Unknown Source)
at com.cnd.corba.ee.impl.transport.SocketOrChannelConnectionImpl.read(Unknown Source)
at com.cnd.corba.ee.impl.transport.ReaderThreadImpl.doWork(Unknown Source)
at com.cnd.corba.plugin.ee.ThreadPoolImpl$WorkAdapter.run(Unknown Source)
at com.cnd.util.ThreadPoolImpl$WorkerThread.run(Unknown Source)
************************
4.线程状态:【in Object.wait()】
"Running ORBWorker-282" prio=10 tid=0x2f194800 nid=0x107c in Object.wait() [0x7c4ee000]
   java.lang.Thread.State: BLOCKED (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x46b47480> (a java.lang.Object)
at com.cnd.corba.ee.impl.transport.SocketOrChannelConnectionImpl.writeLock(Unknown Source)
- locked <0x46b47480> (a java.lang.Object)
at com.cnd.corba.ee.impl.encoding.BufferManagerWriteStream.sendFragment(Unknown Source)
at com.cnd.corba.ee.impl.encoding.BufferManagerWriteStream.sendMessage(Unknown Source)
at com.cnd.corba.ee.impl.encoding.CDROutputObject.finishSendingMessage(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.sendResponse(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(Unknown Source)
at com.cnd.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(Unknown Source)
at com.cnd.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(Unknown Source)
at com.cnd.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(Unknown Source)
at com.cnd.corba.ee.impl.transport.SocketOrChannelConnectionImpl.read(Unknown Source)
at com.cnd.corba.ee.impl.transport.ReaderThreadImpl.doWork(Unknown Source)
at com.cnd.corba.plugin.ee.ThreadPoolImpl$WorkAdapter.run(Unknown Source)
at com.cnd.util.ThreadPoolImpl$WorkerThread.run(Unknown Source)
***********************************
【注意】线程的6种状态:New => Runnable => Terminated => Waiting ||  Timed_wating || Blocked,死锁不是线程的状态。
分享到:
评论

相关推荐

    java thread dump 分析

    Java Thread Dump 分析 Java Thread Dump 分析是 Java 应用程序性能优化的重要工具之一。Thread Dump 是 JVM 的一个快照,记录了当前所有线程的状态,包括线程的 ID、名称、状态、锁信息等。通过分析 Thread Dump,...

    java 线程 dump 分析工具 2.3.3

    java 线程Dump 分析工具: Java的TDA线程转储分析器是一个用于分析Sun Java VM生成的线程转储和堆信息的小型Swing GUI(目前用1.4测试)。它从提供的日志文件中解析线程转储和类直方图。它提供关于发现的线程转储的...

    Java thread dump analyzer (tda)

    Java线程分析工具(TDA)是一款专为Java开发者设计的强大工具,用于解析和理解Java应用程序的线程转储(thread dump)。线程转储是Java虚拟机(JVM)在特定时刻生成的一种快照,其中包含了应用程序中所有活动线程的状态...

    java 内存dump分析和thread dump(java core)分析

    Java内存dump分析和Thread Dump(Java Core)是Java性能调优中的重要环节,它们能帮助开发者定位和解决系统中的各种问题,如内存泄漏、线程阻塞等。下面将详细介绍这两个概念及其分析工具。 首先,Java堆内存dump,...

    Java Thread Dump Analyzing

    Java Thread Dump Analyzing

    IBM java coredump(threaddump) analyzer

    IBM最新java threaddump 分析工具 java -jar jca.jar -Xmx1024m jca.jar

    IBM thread dump文件分析工具

    在Java虚拟机(JVM)的运行过程中,有时会出现性能问题或者系统挂起的情况,这时候我们需要深入了解线程的运行状态,这就是"IBM thread dump文件分析工具"的作用所在。线程dump文件是JVM在特定时刻生成的一种快照,...

    javacore和dump分析工具

    这个文件最重要的作用就是分析 Java 堆内存泄露问题,heap analyzer,MAT 等工具都可以分析这种文件。 Java core 文件保存的是 java 应用程序在崩溃时或任一时刻关于 Java 运行环境的各种信息。包括 Java 虚拟机的...

    JAVA线程dump的分析

    JAVA线程dump的分析 JAVA线程dump是指在JAVA程序中,当前线程的状态和调用堆栈的快照,能够帮助开发者了解当前程序的执行情况,诊断问题和性能瓶颈。生成JAVA线程dump的方法在不同的操作系统下是不同的,在Windows...

    JAVA jvm DUMP 内存分析

    性能测试,线程的 dump 看到线程的 死锁,等待 运行状态

    用Java thread dump 去分析程序的问题

    Java线程转储(Thread Dump)是诊断Java应用程序性能问题和异常情况的重要工具。它提供了一个运行中的Java应用中所有线程的快照,详细显示每个线程的状态、堆栈跟踪以及线程名称。线程状态包括RUNNABLE、BLOCKED、...

    Java线程dump分析脚本

    java线程dump自动分析工具 java线程dump自动分析工具 java线程dump自动分析工具

    Java线程Dump分析工具jstack解析及使用场景

    Java线程Dump分析工具jstack是Java开发人员和运维人员常用的诊断工具,它能够帮助我们了解Java应用程序中线程的状态,以及线程的执行轨迹。本文将深入解析jstack的使用方法及其在不同场景下的应用。 jstack命令的...

    java dump堆栈分析工具

    java dump 堆栈 dumpAnalyzer 分析,在日常工作中,经常会遇到,系统跑着跑着就会出现性能问题,CPU居高不下。这个时候我们就需要对系统的堆栈信息进行分析。这里就介绍如何使用IBM内存检测工具(dumpAnalyzer)。

    JavaDump分析

    JavaDump的使用者通常包括实施、测试和开发人员,他们需要生成和分析JavaDump,以快速诊断和解决Java程序中的各种问题。无论是开发阶段的调试、还是生产环境中的性能优化,JavaDump都是一个不可多得的工具。 生成...

    java Thread Dump Lockness检查死锁

    java Thread Dump 其实就是stack trace。 我们平时经常会碰见java异常,并且得到异常的方法用e.printstacktrace 实际上程序正常运行时也是会有stack trace的,只不过平时不显示出来而已。如何能正常及时显示堆栈信息...

    好用的线程dump分析工具

    好用的线程dump分析工具

    AIX dump分析工具

    "AIX dump分析工具"是专门用于解析和理解这些dump文件的工具,帮助管理员识别并解决Java应用服务器的问题。本文将详细介绍AIX dump分析工具的工作原理、用途以及如何使用它来分析ha398.jar、ga397.zip和jca37.zip等...

    java dump分析工具ha456

    Java Dump分析是Java开发者在遇到性能问题,尤其是内存溢出问题时的重要手段。"ha456"似乎是一个专门用于Java Dump分析的工具,能够帮助我们深入理解内存状况,定位问题源头。本文将详细探讨Java内存分析、dump分析...

    java故障排查ThreadDump

    当Java应用程序出现性能问题、死锁或者线程阻塞等情况时,Thread Dump分析就显得尤为重要。以下是对如何进行Java故障排查,特别是利用Thread Dump进行问题定位的详细说明: 1. **获取Thread Dump** - 使用JDK自带...

Global site tag (gtag.js) - Google Analytics