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);

       </span><span style="color: #0000ff;">new</span> Thread("Thread1-Name"<span style="color: #000000;">) {
           </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> run() {
               System.out.println(</span>"Thread1-Name Start"<span style="color: #000000;">);
               </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> {
                   Thread.sleep(</span>5000<span style="color: #000000;">);
               } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (InterruptedException e) {
                   e.printStackTrace();
               }
               map.put(</span>7, 77);<span style="color: #008000;">//</span><span style="color: #008000;">断点位置 1</span>
      

    System.out.println(map);
    }

        }.start();
        </span><span style="color: #0000ff;">new</span> Thread("Thread2-Name"<span style="color: #000000;">) {
    
            </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> run() {
                </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> {
                    System.out.println(</span>"Thread2-Name Start"<span style="color: #000000;">);
                    Thread.sleep(</span>5000<span style="color: #000000;">);
                } </span><span style="color: #0000ff;">catch</span><span style="color: #000000;"> (InterruptedException e) {
                    e.printStackTrace();
                }
                map.put(</span>3, 33);<span style="color: #008000;">//</span><span style="color: #008000;"> 断点位置2</span>
    

    System.out.println(map);
    }

        }.start();
    
    
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 断点位置 3</span>
        System.out.println("Thread-Main-Name Start"<span style="color: #000000;">);
        System.out.println(</span>"Thread-Main-Name Start"<span style="color: #000000;">);
        System.out.println(</span>"Thread-Main-Name Start"<span style="color: #000000;">);
    
    
        Thread.sleep(</span>500000<span style="color: #000000;">);
    
    }
    

    }

    复制代码

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

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

     

    原文地址:https://www.cnblogs.com/jpfss/p/10944716.html
  • 相关阅读:
    java获取指定日期的前一天和后一天
    Swagger注解-@ApiModel 和 @ApiModelProperty
    Timer中schedule()的用法
    Spring Boot 增加jar包
    报Result Maps collection does not contain value for java.lang.Long错误解决方法
    服务注册组件eureka
    浅谈redission以及Redis分布式锁探索入门
    用Redis实现分布式锁以及redission使用
    JVM逃逸分析对性能的影响
    【HTML打印】HTML直接调用window下的打印机并执行打印任务(简单打印任务生成)
  • 原文地址:https://www.cnblogs.com/jpfss/p/10944716.html
Copyright © 2011-2022 走看看