java倒计时简易实现,只按单线程,以秒为单位

public class Countdown {
private int lin;
public Countdown(int lin)throws InterruptedException{
this.lin = lin;
System.out.println("最后倒数时刻:" + lin + "秒" + " ");
while (lin > 0){
System.out.println("倒计时: "+ --lin +"秒");
TimeUnit.SECONDS.sleep(1);
}
System.out.println("Game over!!!");
}

public static void main(String[] args) throws InterruptedException{
new Countdown(30);
}
}
原文地址:https://www.cnblogs.com/THEONLYLOVE/p/9114986.html