返回列表 發帖
本帖最後由 張健勳 於 2018-5-25 19:12 編輯
  1. package bbs.istak.org.tw;

  2. public class Main {

  3.         public static void main(String[] args) {
  4.                 new myThread().start();
  5.         }
  6. }

  7. class myThread extends Thread
  8. {
  9.         public void run()
  10.         {
  11.                 for( int i=5; i>=1; i--)
  12.                 {
  13.                         try {
  14.                                 Thread.sleep(1000);
  15.                         } catch (InterruptedException e) {
  16.                         }
  17.                        
  18.                         System.out.println(i+"秒");
  19.                 }
  20.                 System.out.println("Time Out!!!");
  21.                 System.out.println("執行緒名稱:"+Thread.currentThread().getName());

  22.         }
  23.         }
複製代碼

TOP

返回列表