返回列表 發帖
  1. public class Ch100  extends Thread{

  2.         public void run() {
  3.                 for(int i=5;i>=1;i--)
  4.                 {
  5.                         System.out.println(i+"秒");
  6.                         try{
  7.                                 Thread.sleep(1000);
  8.                         }catch(InterruptedException e) {}
  9.                 }
  10.            System.out.println("時間到");
  11.            System.out.println("執行緒名稱:"+Thread.currentThread().getName());
  12.         }
  13.         public static void main(String[] args)
  14.         {
  15.                 Ch100 app=new Ch100();
  16.                 app.run();
  17.         }
  18. }
複製代碼

TOP

返回列表