This content has been marked as final. Show 2 replies
Your problem is calculating the delay, not necessarily to do with concurrency. Secondly, you may want to use code tags around your snippets of code like [ code ] and [ /code ] (without the spaces) to get nicely formatted source code.
I "hate" working on pieces of code that depend on the actual system time. To avoid using the system time, I code against an input parameter that represent the current time. At the point where I use the code a call it with the system clock time:
and there are many variations on this idea (a no-arg method that calls a one arg method that does the real work)
Perhaps this gives you an idea how to debug your own attempts a bit easier...
Took a slightly closer look at your code, so far the only things wrong are the value for fONCE_PER_DAY (24*60*60*1000) and using fZERO_AM instead of fFOUR_AM. I really don't know how fiddling with the system's clock is perceived by Java. Are your changes propogated to the system, did you advance the date too when you go to 4AM, our did you put the clock on today's 4AM?
But I'd be very willing to say that if this works for 09:45AM when I say so, it works just as well at 04:00AM while I am not watching... (assumptions are the roots of all evil)