名称jstack: stack trace
摘要:
jstack [ option ] pid
jstack [ option ] executable core
jstack [ option ] [server-id@]remote-hostname-or-IP
功能:
jstack 打印出指定的java进程、core文件或远程调试服务的调用栈信息。包括类全面,方法名称,byte code index和代码行号。指定-m参数还可以打印出本地方法调用栈. 可以快速定位程序问题.
参数说明:
pid process id for which the stacktrace is to be printed. The process must be a Java process. To get a list of Java processes running on a machine, jps may be used.
executable Java executable from which the core dump was produced.
core core file for which the stack trace is to be printed.
remote-hostname-or-IP remote debug server's (see jsadebugd) hostname or IP address.
server-id optional unique id, if multiple debug servers are running on the same remote host.
OPTION 选项:
-m 打印java和本地混合调用栈.
-h -help打印帮助信息
示例:
说明:
ltu-1是进程名称, prio优先级, tid java线程id, nid native线程id. java.lang.Thread.State:WAITING线程状态.
locked <0x00000007955b0850>已经进入临界区
waiting:线程等待被唤醒.对应的代码如下:
new Thread(new Runnable() {
@Override
public void run(){
synchronized (i){
try {
i.wait();
}catch (InterruptedException e){
}
}
}
}, "ltu-1").start();