返回列表 發帖
  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.                                 Thread.sleep(1000);
  10.                         } catch (Exception e) {        }
  11.                 }
  12.                 System.out.println("時間到");
  13.                 System.out.println("執行緒名稱:"+Thread.currentThread().getName());
  14.         }
  15.         public static void main(String args[])
  16.         {
  17.                 (new Ch122()).start();
  18.         }
  19. }
複製代碼

TOP

返回列表