public class Main { static class MyThread extends Thread { @Override public void run() { while (true) { System.out.println("hello thread"); try { Thread.sleep(1000); } catch (InterruptedException e) { throw new RuntimeException(e); } } } } public static void main(String[] args) { MyThread t = new MyThread(); t.start(); while (true) { System.out.println("hello main"); } } } 找到你安装的 jdk 文件夹
进入 bin 文件夹
使用管理员权限运行 jconsole.exe
选择你要查看的线程
选择线程标签页

代码中自己创建的线程命名的规律就是 Thread-数字
除了我们创建的Thread和main,还有很多线程

这些线程都是起到了一些辅助作用.
在调试过程中