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

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

TOP

返回列表