Re: System clock runs fast
Well, ok, so java does not guarentee timing by any sense of the word. Everything in java with regards to time is an "I'll try my best" and should be treated as approximate.
For example, if you intended for an app to run for 1 second by sleeping for 10 intervals of 100ms, you would get close but not-perfect results. This is not the way to handle timing in java.
Values from System.currentTimeMillis() should be reasonably accurate though, so to track elapsed time the best approach would be to mark down the current time at the start of application/method/loop whatever, and periodically subtract that time from the current time to see how much time has passed.
Quote:
system clock starts running fast and gains almost 10 seconds every 1 min.
How are you determining this? Like I said, if you were coding a virtual clock and set it's time using Sleep() or something like that, then this would be the expected result. Your clock would go fast or slow depending on current system load (since java's time values are at the mercy of when the JVM can get a scheduled time call in to the Host OS).
The proper way to code a digital clock would be to periodically compare the current time to the last saved time (like I mentioned above) and if 1000ms have elapsed, then increment the clock.
Does this make sense? If you posted a small code same that demonstrates the problem, it would be easier to suggest a solution!