为什么创建的线程数和用Thread.activeCount()方法得到的数字不同?
先给上源码
public class ThreadCount extends Thread {
char c;
public ThreadCount(String name, char c) {
super(name);
this.c = c;
}
public void run(){
int k;
char ch = c;
System.out.println();
System.out.print(getName()+": ");
for(k = 0; k <= 2; ++k) {
ch = (char)(c+k);
System.out.print(ch + " ");
}
System.out.println(getName()+"end!");
}
public static void main(String[] args) {
ThreadCount threadCount1 = new ThreadCount("th1", 'A');
ThreadCount threadCount2 = new ThreadCount("th2", 'a');
threadCount1.start();
threadCount2.start();
System.out.println("activeCount= " + Thread.activeCount());
}
}
就是这样的一个代码,运行出来的结果activeCount是4,我觉得是th1,th2和main三个线程啊,还会别的东西吗?请各位大佬解释一下