zoukankan      html  css  js  c++  java
  • IDEA多线程下多个线程切换断点运行调试的技巧

    多线程调试设置可以参考:http://www.cnblogs.com/leodaxin/p/7710630.html

    1 断点设置如图:

    2 测试代码,然后进行debug

    package com.daxin;
    
    import java.util.HashMap;
    
    /**
     * Created by Daxin on 2017/10/22.
     */
    public class HashMapInfiniteLoop {
        private static HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(2, 0.75f);
    
        public static void main(String[] args) throws InterruptedException {
            map.put(5, 55);
    
            new Thread("Thread1-Name") {
                public void run() {
                    System.out.println("Thread1-Name Start");
                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    map.put(7, 77);//断点位置 1
                    System.out.println(map);
                }
    
            }.start();
            new Thread("Thread2-Name") {
    
                public void run() {
                    try {
                        System.out.println("Thread2-Name Start");
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    map.put(3, 33);// 断点位置2
                    System.out.println(map);
                }
    
            }.start();
    
    
            // 断点位置 3
            System.out.println("Thread-Main-Name Start");
            System.out.println("Thread-Main-Name Start");
            System.out.println("Thread-Main-Name Start");
    
    
            Thread.sleep(500000);
    
        }
    }

    3:启动debug,我们可以在Threads Tab选项双击需要进行单步调试的线程

    然后选择Frames Tab选项中调试的线程进行快捷键调试即可。

     

  • 相关阅读:
    定义serialVersionUID的作用与意义整理
    HttpClient学习整理
    Eclipse+TestNG搭建接口自动化测试框架
    Jmeter之Bean shell使用(一)
    吴军博士的《数学之美》(摘录)
    SqlServer—大话函数依赖与范式
    MySQL—FOREIGN KEY
    MYSQL-用户操作
    WAMPServer 默认安装启动后,图标显示橙黄色
    Linux time命令
  • 原文地址:https://www.cnblogs.com/leodaxin/p/7710764.html
Copyright © 2011-2022 走看看