--------------------------napolun180410-----------------------------
public class MyThread extends Thread{
public void run(){
try{
for(int i=1;i<6;i++){
System.out.println(i);
sleep(2000);
}
}
catch(InterruptedException e){}
}
public static void main(String args[]){
System.out.println("当前的线程数:"+Thread.activeCount());
MyThread thread1=new MyThread();
thread1.start();
System.out.println("当前的线程数:"+Thread.activeCount());
MyThread thread2=new MyThread();
thread2.start();
System.out.println("当前的线程数:"+Thread.activeCount());
}
}
文件名 MyThread.java (注意大小写,别改文件名)
--------------------------有问题发消息我----------------------------