import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
public class TimerTest {
public static void main(String[] args) {
Calendar calendar = Calendar.getInstance();
Date firstTime = calendar.getTime();
// 间隔:2分钟
long period = 1000 * 60 * 2;
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
// 执行你的方法
}
}, firstTime, period);
}
}