idea中多线程调试技巧

示例代码

复制代码
public class Lesson091 {
    public static void main(String[] args) {
        //下面创建3个线程:thread1、thread2、thread3
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 50; i++) {
                System.out.println(Thread.currentThread() + " " + i);
            }
        }, "thread1");

        Thread thread2 = new Thread(() -> {
            for (int i = 0; i < 50; i++) {
                System.out.println(Thread.currentThread() + " " + i);
            }
        }, "thread2");

        Thread thread3 = new Thread(() -> {
            for (int i = 0; i < 50; i++) {
                System.out.println(Thread.currentThread() + " " + i);
            }
        }, "thread3");

        thread1.start();
        thread2.start();
        thread3.start();
    }
}

idea 设置如下

效果如下,点击切换,就单独调试某个线程

相关推荐
一嘴一个橘子1 天前
mybatis-plus 基于 service 接口的 crud
java
Java小卷1 天前
KIE Drools 10.x 规则引擎快速入门
java·后端
fengsen52113141 天前
Windows操作系统部署Tomcat详细讲解
java·windows·tomcat
竟未曾年少轻狂1 天前
Spring Boot 项目集成 Redis
java·spring boot·redis·缓存·消息队列·wpf·redis集群
_codemonster1 天前
java web修改了文件和新建了文件需要注意的问题
java·开发语言·前端
Java天梯之路1 天前
Spring Boot 钩子全集实战(九):`@PostConstruct` 详解
java·spring boot·后端
松涛和鸣1 天前
75、 IMX6ULL LM75温度传感器I2C驱动开发
java·linux·数据库·驱动开发·python
独自破碎E1 天前
BISHI41 【模板】整除分块
java·开发语言
毕设源码-郭学长1 天前
【开题答辩全过程】以 基于Springboot图书管理系统为例,包含答辩的问题和答案
java·spring boot·后端
云小逸1 天前
【Vscode插件开发教程】VSCode插件开发入门指南:从C++开发者的视角
c++·ide·vscode