在Linux上输入top
进入top后按【shift】+【H】组合键,按线程方式查看线程ID、CPU消耗状况等
通过这种方式获取耗CPU的线程后查看ThreadDump文件做进一步分析
获取ThreadDump的方法:
线程名称: Attach Listener
* 线程类型:daemon
* 优先级:10,默认是5
* jvm线程id:jvm内部线程的唯一标识, 0x00007fd388001000
* 对应系统线程id:和top命令查看的pid对应,不过一个是10进制,一个是16进制。0x76e6
* 线程状态:waiting on condition
* 起始栈地址: [0x0000000000000000]
线程状态详解
[b]Runnable[/b]
_The thread is either running or ready to run when it gets its CPU turn.
[b]Wait on condition[/b]
_The thread is either sleeping or waiting to be notified by another thread._
[b] Waiting for Monitor Entry and in Object.wait()[/b]
_The thread is waiting to get the lock for an object (some other thread may be holding the lock). This happens if two or more threads try to execute synchronized code. Note that the lock is always for an object and not for individual methods._
进入top后按【shift】+【H】组合键,按线程方式查看线程ID、CPU消耗状况等
通过这种方式获取耗CPU的线程后查看ThreadDump文件做进一步分析
获取ThreadDump的方法:
jstack -l pid >jstack.log
"Attach Listener" daemon prio=10 tid=0x00007fd388001000 nid=0x76e6 waiting on condition [0x0000000000000000]
线程名称: Attach Listener
* 线程类型:daemon
* 优先级:10,默认是5
* jvm线程id:jvm内部线程的唯一标识, 0x00007fd388001000
* 对应系统线程id:和top命令查看的pid对应,不过一个是10进制,一个是16进制。0x76e6
* 线程状态:waiting on condition
* 起始栈地址: [0x0000000000000000]
线程状态详解
[b]Runnable[/b]
_The thread is either running or ready to run when it gets its CPU turn.
[b]Wait on condition[/b]
_The thread is either sleeping or waiting to be notified by another thread._
[b] Waiting for Monitor Entry and in Object.wait()[/b]
_The thread is waiting to get the lock for an object (some other thread may be holding the lock). This happens if two or more threads try to execute synchronized code. Note that the lock is always for an object and not for individual methods._