Oct 01

The java.util.Timer class can be used to schedule code to be executed in the future. The TimerTask class is used to encapsulate the code to bbe executed.


Date whenToExecute = getTimeToExecuteCode();
Timer timer = new Timer();
timer.schedule(new TimerTask()
{
    public void run()
    {
        // put the code you want to run here
    }
}, whenToExecute); 

written by objects \\ tags: ,

Oct 01

The java.util.Timer class can be used to schedule code to be execute in the future. The TimerTask class is used to encapsulate the code to be executed.


int delay = 5000; //msecs
Timer timer = new Timer();
timer.schedule(new TimerTask()
{
    public void run()
    {
        // put the code you want to run here
        // It will get executed in 5000 msecs
    }
}, delay); 

written by objects \\ tags: ,