开发者

Can I get a notification if clock changed/adjusted?

开发者 https://www.devze.com 2023-02-16 13:29 出处:网络
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?

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:

  1. Fetches the current clock time and stores it in a variable V
  2. Sleeps for X milliseconds
  3. Adds X to V, compares it to the current clock time
  4. If the values don't match to within a few milliseconds, assume the clock has changed, and trigger a reschedule
  5. Rinse and repeat
0

精彩评论

暂无评论...
验证码 换一张
取 消