返回列表 發帖
  1. public class Ch123 {
  2.         private MyThread th;
  3.        
  4.         Ch123(){
  5.                 th=new MyThread();
  6.                 th.start();
  7.         }
  8.        
  9.         public static void main(String[] args) {
  10.                 new Ch123();
  11.         }
  12. }

  13. class MyThread extends Thread{
  14.         public void run(){
  15.                 for(int i=5; i>=1; i--){
  16.             System.out.println(i+"秒");
  17.             try{
  18.                     Thread.sleep(1000);
  19.             }catch(InterruptedException e){}
  20.             }
  21.             System.out.println("時間到");
  22.             System.out.println("執行緒名稱: "+ Thread.currentThread().getName());
  23.         }
  24. }
複製代碼
كخخخخخخخخخخخخخ

TOP

返回列表