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 设置如下

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

相关推荐
Sammyyyyy20 分钟前
Rust 1.92.0 发布:Never Type 进一步稳定
java·算法·rust
alonewolf_9930 分钟前
深入解析G1与ZGC垃圾收集器:原理、调优与选型指南
java·jvm·算法
小镇学者31 分钟前
【c++】C++字符串删除末尾字符的三种实现方法
java·开发语言·c++
rfidunion33 分钟前
springboot+VUE+部署(1。新建项目)
java·vue.js·spring boot
小翰子_33 分钟前
Spring Boot整合Sharding-JDBC实现日志表按月按周分表实战
java·spring boot·后端
weixin_3993806941 分钟前
OA 系统假死问题分析与优化
java·运维
豆沙沙包?1 小时前
2026年--Lc334-2130. 链表最大孪生和(链表转数组)--java版
java·数据结构·链表
柒.梧.1 小时前
SSM常见核心面试问题深度解析
java·spring·面试·职场和发展·mybatis
杨章隐1 小时前
Java 解析 CDR 文件并计算图形面积的完整方案(支持 MultipartFile / 网络文件)@杨宁山
java·开发语言
Renhao-Wan2 小时前
Java 并发基石:AQS (AbstractQueuedSynchronizer)
java·开发语言