java倒计时器

package com.changyou;

import java.util.concurrent.*;  
  
public class CountDown {  
    public CountDown(int limitSec) throws InterruptedException{  
        System.out.println("Count from "+limitSec);  
        while(limitSec > 0){  
            System.out.println("remians "+ --limitSec +" s");  
            TimeUnit.SECONDS.sleep(1);  
        }  
        System.out.println("Time is out");  
    }  
      
  public static void main(String[] args) throws InterruptedException { 
        new CountDown(30); 
    } 
  
}  

 

posted on 2017-11-29 10:04  马文奇  阅读(566)  评论(0编辑  收藏  举报

导航