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

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

相关推荐
禾小西14 分钟前
Spring AI :Spring AI的介绍
java·人工智能·spring
愤豆18 分钟前
05-Java语言核心-语法特性--模块化系统详解
java·开发语言·python
bksczm19 分钟前
文件流(fstream)
java·开发语言
NGC_661120 分钟前
Java 线程池阻塞队列与拒绝策略
java·开发语言
小碗羊肉32 分钟前
【从零开始学Java | 第二十二篇】List集合
java·开发语言
m0_7167652334 分钟前
C++提高编程--STL常用容器(set/multiset、map/multimap容器)详解
java·开发语言·c++·经验分享·学习·青少年编程·visual studio
qqty12171 小时前
springboot+mybaties项目中扫描不到@mapper注解的解决方法
java·spring boot·mybatis
灵魂猎手1 小时前
14. MyBatis XML 热更新实战:告别重启烦恼
java·mybatis
程途知微1 小时前
AQS 同步器——Java 并发框架的核心底座全解析
java·后端
sunwenjian8861 小时前
SpringBean的生命周期
java·开发语言