本帖最後由 李允軒 於 2016-10-1 17:35 編輯
- public class Ch122 extends Thread{
- public void run(){
- for(int i=5; i>=1; i--){
- System.out.println(i+"秒");
- try{
- Thread.sleep(1000);
- }catch(InterruptedException e){}
- }
- System.out.println("時間到");
- System.out.println("執行緒名稱: "+ Thread.currentThread().getName());
- }
- public static void main(String[] args) {
- Ch122 app=new Ch122();
- app.start();
- }
- }
複製代碼 |