java代码执行过慢的问题定位

  1. public class Test {  
  2.     public static void main(String[] args) throws InterruptedException {  
  3.         int i=0;  
  4.         while(true){  
  5.             System.out.println("Hello world !"+i);  
  6.             i++;  
  7.             Thread.sleep(100);  
  8.         }  
  9.     }  
  10. }  

1.ps -ef |grep java 找出最耗性能的JAVA进程
2.top -Hp "进程ID"找出最耗时间的JAVA线程
3.printf "%x/n" "PID"转换成16进制
4.jstack "进程ID" |grep "线程ID"

"main" prio=10 tid=0x00007fdc58009800 nid=0x6a8 waiting on condition [0x00007fdc5e198000]

另外一些APM工具也可以帮助进行性能定位

http://blog.csdn.net/neutrojan/article/details/50532590

原文地址:https://www.cnblogs.com/lnas01/p/5917104.html