名稱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();