gyjx2016

演示代码

public class StackTest {

    public static void main(String[] args) {
        Thread thread = new Thread(new Worker());
        thread.start();
    }

    static class Worker implements Runnable {
        @Override
        public void run() {
            while (true) {
               /* try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }*/
                System.out.println("Thread Name:" + Thread.currentThread().getName());
            }
        }
    }
}

 

[root@localhost opt]# java -jar jstack-demo.jar

 

 

top命令查看CPU使用情况,默认按照CPU使用率从高到低排序,如果没排,请使用M指令进行排序。

 

 查看到消耗CPU第一的进程ID是2047,查看当前进程下的线程信息,

[root@localhost ~]# top -Hp 2047

 

 

 将这个线程ID,十进制转为16进制,

[root@localhost ~]# printf  "%x" 2059

 

 jstack 命令查看具体的异常位置,便于我们优化代码

[root@localhost ~]# jstack -l 2047

 

 

 

分类:

技术点:

相关文章:

  • 2021-11-16
  • 2021-10-17
  • 2019-02-15
  • 2021-11-13
  • 2021-10-17
  • 2021-04-20
猜你喜欢
  • 2022-01-08
  • 2021-10-17
  • 2022-01-08
  • 2022-01-08
  • 2021-09-27
  • 2021-10-17
  • 2021-10-10
相关资源
相似解决方案