简介
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();
}
}