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

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

相关推荐
雨奔6 小时前
Kubernetes DNS 完全指南:服务发现核心机制与实践
java·kubernetes·服务发现
逻辑驱动的ken6 小时前
Java高频面试考点场景题14
java·开发语言·深度学习·面试·职场和发展·求职招聘·春招
阿冰冰呀6 小时前
互联网大厂Java求职面试实录:谢飞机的“水货”之路
java·mybatis·dubbo·springboot·线程池·多线程·hashmap
水无痕simon6 小时前
1.单机部署Nacos1.3.2
java
Java小生不才8 小时前
spring AI文生图
java·人工智能·spring ai
苍煜8 小时前
ThreadPoolExecutor线程池终极全解:同步异步判定+SpringBoot生产实战
java·开发语言·spring boot
c++之路9 小时前
C++ 动态内存
java·jvm·c++
2301_8009769313 小时前
数据库的基本操作后续
java·数据库·sql
SECS/GEM13 小时前
SECS/GEM如何实现越南现场自定义消息
java·服务器·数据库
lv__pf13 小时前
集合框架1
java·开发语言