package com.happy.timer;  
  
import java.util.Date;  
import java.util.Timer;  
import java.util.TimerTask;  
 
public class TimerDo {  
    public static void main(String[] args) {  
        Integer cacheTime = 1000 * 3;  
        Timer timer = new Timer();  
        // (TimerTask task, long delay, long period)任务,延迟时间,多久执行  
        timer.schedule(new TimerTask() {  
  
            @Override  
            public void run() {  
                System.out.println(new Date());  
            }  
        }, 1000, cacheTime);  
    }  
}