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

  18.         public static void main(String[] args)
  19.         {
  20.                 Ch121 app=new Ch121();
  21.                 app.start();
  22.         }

  23. }
複製代碼

TOP

返回列表