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

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

相关推荐
WiChP4 小时前
【V0.1B5】从零开始的2D游戏引擎开发之路
java·服务器·数据库
cch89184 小时前
汇编与Java:底层与高层的编程对决
java·开发语言·汇编
荒川之神5 小时前
拉链表概念与基本设计
java·开发语言·数据库
cch89185 小时前
汇编与Go:底层到高层的编程差异
java·汇编·golang
杂家5 小时前
WebStorm搭建Vue3+Element Plus
ide·webstorm
chushiyunen5 小时前
python中的@Property和@Setter
java·开发语言·python
禾小西5 小时前
Java中使用正则表达式核心解析
java·python·正则表达式
yoyo_zzm5 小时前
JAVA (Springboot) i18n国际化语言配置
java·spring boot·python
APIshop6 小时前
Java获取京东商品详情接口(item_get)实战指南
java·linux·数据库