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 分钟前
Python GeoPandas基础知识:地图、投影和空间连接
开发语言·ide·python
vx1_Biye_Design3 分钟前
基于Spring Boot+Vue的学生管理系统设计与实现-计算机毕业设计源码46223
java·vue.js·spring boot·spring·eclipse·tomcat·maven
vx_Biye_Design5 分钟前
基于Spring Boot+vue的湖北旅游景点门票预约平台的设计--毕设附源码29593
java·vue.js·spring boot·spring cloud·servlet·eclipse·课程设计
hay_lee23 分钟前
Spring AI实现对话聊天-流式输出
java·人工智能·ollama·spring ai
Hx_Ma1629 分钟前
SpringBoot数据源自动管理
java·spring boot·spring
SunnyDays101130 分钟前
Java 高效实现 CSV 转 Excel
java·csv转excel
starfire_hit31 分钟前
JAVAWEB根据前台请求获取用户IP
java·服务器·网络
fengxin_rou32 分钟前
[Redis从零到精通|第四篇]:缓存穿透、雪崩、击穿
java·redis·缓存·mybatis·idea·多线程
像少年啦飞驰点、36 分钟前
从零开始学 RabbitMQ:小白也能懂的消息队列实战指南
java·spring boot·微服务·消息队列·rabbitmq·异步编程
宠友信息43 分钟前
2025社交+IM及时通讯社区APP仿小红书小程序
java·spring boot·小程序·uni-app·web app