- public class Ch123 extends Thread{
- Ch123(){
- start();
- }
- public void run(){for(int i=5;i>=1;i--){
- System.out.println(i+"seconds");
- try{
- Thread.sleep(1000);
- }catch(InterruptedException e){}
- }
- System.out.println("Time's up!");
- System.out.println("Thread's name:"+Thread.currentThread().getName());
- }
- public static void main(String[] args){
- Ch123 jock=new Ch123();
- jock.start();
- }
- }
複製代碼 |