定时器
package com.funo.timer;
import java.util.Timer;
public class MyTimer {
public static void main(String[] args) {
Timer timer =new Timer();
timer.schedule(new MyTimerTask(),2000,3000);
}
}
//----------------------------------------------------------------
package com.funo.timer;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimerTask;
public class MyTimerTask extends TimerTask {
@Override
public void run() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println("doing timer task"+sdf.format(new Date()));
}
}