日期:2014-05-20 浏览次数:20688 次
import java.util.Timer;
import java.util.TimerTask;
public class TimerTaskDemo {
public static void main(String[] args) {
final Timer timer = new Timer();
timer.schedule(new TimerTask() {
private int count = 30;
@Override
public void run() {
if(count > 0){
System.out.println(count--);
}else{
timer.cancel();
}
}
}, 0, 1000);
}
}