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

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

TOP

返回列表