Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TimerTask set to 1 day

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have used timertask code that will run at a specified minutes. But now I am thinking if this code
will be ok?



I am not sure if I set the execution period to at least a day will have no problem.
As per my reading and google in the internet, they suggest some sort of scheduling framework such as quartz
to do what I want.

But given just below code, do you think it still is dependable to execute my timertask in 1 day period?
I plan to use this only in windows?

Please advise.
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will run once each day on roughly the same time, except when daylight savings time kicks in. A day will then have either 23 or 25 hours, not 24.
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob,

Thanks for your replies..

That is what I want, have it run exactly the same time the next day. No problem if it might be delayed as long as it runs with no problem.

I have used timertask before but the interval that I set are small and runs about an hour. This time I used 24 hour as my period so I am
not sure if in the long run there will be no problem.

Also, I have check the Timer API and have found the scheduleAtFixedRate method. I was thinking that this is the right method that I need instead of the
schedule method.
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said before, daylight savings time will shift your schedule back once a year and back once a year. I'm sure that scheduling frameworks like Quartz have solved this already.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic