黑马程序员 java基础 继承thread多线程学习日志
《JAVA程序设计》
public class FirstThread extends Thread{
public FirstThread(String threadName){
super(threadName);
}
public void run(){
for(int temp = 1; temp <= 5; temp++){
System.out.println("第" + temp + "次" + this.getName());
try{
this.sleep(1000);
}
catch(Exception e){}
}
}
public static void main(String[] args){
FirstThread thread1 = new FirstThread("线程1");
FirstThread thread2 = new FirstThread("线程2");
thread1.start();
thread2.start();
}
}