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

TOP

返回列表