提问,为社么是4不是3啊?关于简单的THREAD
package threads;
public class PrintStatic implements Runnable{
public static void main(String[] args){
Thread t1=new Thread(new PrintStatic(),"First Thread");
t1.start();
Thread t2=new Thread(new PrintStatic(),"Second Thread");
t2.start();
int numThreads=Thread.activeCount();
System.out.println("The number of threads is: "+numThreads);
Thread[] threads=new Thread[numThreads];
Thread.enumerate(threads);
for(int i=0;i<3;i++)
System.out.println(" Thread named: "+threads[i].getName());
}
public void run(){
try{
Thread.sleep(1000);
}catch(InterruptedException e){
System.out.print("Oh no !I was interrupted");
}
System.out.print("dd");
}
}
System.out.println("The number of threads is: "+numThreads);
书上是3,WHY我的机器上是4