2秒后执行run方法里的任务
Timer timer = new Timer();
System.out.println(new Date());
TimerTask task = new TimerTask() {
@Override
public void run() {
System.out.println("1---" + new Date());
}
};
timer.schedule(task, 2000);
2秒后执行run方法里的任务
Timer timer = new Timer();
System.out.println(new Date());
TimerTask task = new TimerTask() {
@Override
public void run() {
System.out.println("1---" + new Date());
}
};
timer.schedule(task, 2000);