jvisualvm 的使用

时间:2021-08-11 19:23:09   收藏:0   阅读:33

简介

1.8版本以后不自带这个工具
1.7中有, 然后需要手动从 https://visualvm.github.io/pluginscenters.html 下载自己对应的 visualGC插件, 否则看不到
本地的方法可以直接看到, 可以直接查看.

image

技术分享图片

code

/**
 * Created by lee on 2021/8/11.
 */
public class While {
    class MyThread extends Thread{
        @Override
        public void run() {
            StringBuilder s=new StringBuilder("dafdsa");
            while(true) {
                try {
                    System.out.println("进入睡眠状态");
                    Thread.currentThread().sleep(100);
                    int j=0;

                    for(int i=0; i<10000; i++) {
                        j+=i;
                        s.append("dafds");
                        s.append(i);
                    }
                    int aa[] = new int[1024*1024*10];
                    System.out.println("睡眠完毕");
                    System.out.println(s);
                } catch (InterruptedException e) {
                    System.out.println("得到中断异常");
                }
                System.out.println("run方法执行完毕");
            }

        }
    }
    public static void main(String[] args) {
        While w = new While();
        MyThread thread = w.new MyThread();
        thread.start();
        try {
            Thread.currentThread().sleep(2000);
        } catch (InterruptedException e) {

        }
        thread.interrupt();
    }

}

原文:https://www.cnblogs.com/eat-too-much/p/15129286.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!