Can I get a notification if clock changed/adjusted?
I have a program which relies on the clock-time to do some recurring tasks. How can I tell that clock was changed and I need to re开发者_如何学编程-adjust my tasks?
EDIT: I am using a Date
instance to see if time already passed or not.
Start a new thread which:
- Fetches the current clock time and stores it in a variable V
- Sleeps for X milliseconds
- Adds X to V, compares it to the current clock time
- If the values don't match to within a few milliseconds, assume the clock has changed, and trigger a reschedule
- Rinse and repeat
精彩评论