java.util.Timer;
import java.util.TimerTask;
public class CountDown extends TimerTask {
private Timer timer;
private int count;
public CountDown() {
count = 10;
timer = new Timer();
timer.scheduleAtFixedRate(this, 0l, 1000l);
}
public void run() {
System.out.println("Count: " + count);
if (count == 0) {
cancel();
timer.cancel();
} else {
count--;
}
}
public static void main(String args[]) {
new CountDown();
}
}