This Java tip illustrates a method of scheduling a timer for a task to run at a certain time. Developer may use this code if there is a need to execute or repeat a task in an application at a predefined interval of time.

 int interval = 10000; // 10 sec
    Date timeToRun = new Date(System.currentTimeMillis() + interval);
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
            public void run() {
                // Task here ...
        }, timeToRun);