The default number of global threads for idea is 2. Why?

debug

Mar.01,2021

use Thread.currentThread (). GetThreadGroup (). List () to list which threads belong to the current thread group. The output format of the thread is [thread name, thread priority, thread group name]:

public class Main {

    public static void main(String[] args) {

        Thread.currentThread().getThreadGroup().list();

    }
}

run result:

it can be seen that in addition to the main thread ("Thread [main]"), there is also a "Monitor Ctrl-Break" thread, which should be the monitoring thread of your program started by IDEA through reflection, along with your program. This is not a problem. The official API also said that Thread.activeCount () only returns an estimate, so you can't rely on this value to determine how many threads are currently running.


Open the application jvisualvm.exe
under the bin directory under javahome to see the detailed thread status, and all threads in your debug mode can see

Menu