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
  • 相关阅读:
    BootStrap行内编辑
    NPOI学习笔记
    仅当使用了列列表并且 IDENTITY_INSERT 为 ON 时,才能为表'Address'中的标识列指
    .Net MVC发布出错 Server Error in '/' Application.
    C# 新特性
    System.Runtime.InteropServices.COMException:“服务器出现意外情况。 (异常来自
    BootStrap的表格加载json数据,并且可以搜索,选择
    NPOI导入导出Excel
    读取Easy UI的DATa grid里面的所有数据
    C# 导出Excel
  • 原文地址:https://www.cnblogs.com/jpfss/p/10944716.html
Copyright © 2011-2022 走看看