IDEA Debug tips add and reduce the variables viewed, view different threads

question

IDEA's Debug must have been used. What is the way of the variables shown below it? Can you add variables and view threads?

The answer is: yes .

demo code

code show as below:

package cn.itcast.attempt.threadAttempt.attempt2;

public class Test {
    public static void main(String[] args) {
        // 演示添加、减少查看变量
        int count1 = 0;
        int count2 = 100;
        for (int i = 0; i < 100; i++) {
            count1 += i;
        }

        count2 = 100;
        for (int i = 0; i < 100; i++) {
            count2 -= i;
        }

        System.out.println("===========");

        // 演示查看线程
        MyRun myRun = new MyRun();
        Thread t1 = new Thread(myRun);
        Thread t2 = new Thread(myRun);

        t1.start();
        t2.start();
    }
}

Increase and decrease viewing variables

Click the small arrow on the left of the variable interface to add the viewed variable.

After jumping out of the input box, enter the variable name you want to view:

 (Then I ran a few steps back) It is also possible to delete the viewed variable, just click the minus sign:

View different threads

Below the code, there are two threads t1 and t2. After the threads are running, we can check it on the left side of the variable viewing box:

 

Guess you like

Origin blog.csdn.net/m0_46948660/article/details/132023780