返回列表 發帖
  1. public class Ch123 extends Thread{
  2.         Ch123(){
  3.                 start();
  4.         }
  5.         public void run(){for(int i=5;i>=1;i--){                       
  6.                 System.out.println(i+"seconds");
  7.                 try{
  8.                         Thread.sleep(1000);                               
  9.                 }catch(InterruptedException e){}
  10.         }
  11.         System.out.println("Time's up!");
  12.         System.out.println("Thread's name:"+Thread.currentThread().getName());
  13.     }
  14.         public static void main(String[] args){               
  15.                 Ch123 jock=new Ch123();
  16.                 jock.start();
  17.         }
  18. }
複製代碼

TOP

返回列表