tags:

views:

149

answers:

2

Hi All,

Can I overload the Java Timer Task to have it execute every one day?

Timer timer = new Timer(true);
timer.schedule(new SendEmailTask(), 6000000, 86400000);  //schedule to run one day?

Will there be no problem if I implement below period?

+1  A: 

the timer will execute the SendEmailTask() after a delay of 6000000 ms and then every 86400000 ms, starting from the time your application starts to run.

you are not overloading the timer your are merely using an instance of a timer.

it goes without saying that if your application is not running your timer event wont execute as well.

Alon
A: 

Are you trying to get the timer to run once every day at exactly the same time of day? If so, try Timer.scheduleAtFixedRate (the Timer.schedule method will expire a specified period after the previous expiry; scheduleAtFixedRate expires a specified period after the initial delay.

Ash
Hi, This is what I would like to do.. I want my timer task to run once everyday on exactly the same time of the other day.So If I used scheduleAtFixedrate, there will be no problem even if my period is equivalent to one day?Will I not run into any problem even if I have a great value of period?
Rex Mercardo
As far as I know java.util.Timer should work with large periods.
Ash
Hi Ash and Alon, Thank you very much for taking time out in answering my question...
Rex Mercardo