使用如下:
public static void main(String[] args) {
Timer timer = new Timer();
int i = 0;
timer.scheduleAtFixedRate(new TimerTask() {
int i = 0;
public void run() {
System.out.println("运行了!"+i);
i++;
}
}, new Date(), 5000);
}
使用如下:
public static void main(String[] args) {
Timer timer = new Timer();
int i = 0;
timer.scheduleAtFixedRate(new TimerTask() {
int i = 0;
public void run() {
System.out.println("运行了!"+i);
i++;
}
}, new Date(), 5000);
}