Don't confuse the precision of the time value with its accuracy. Just
because the return value is capable of reporting time to the nearest
millisecond does not mean that the underlying implementation can
report values with that accuracy. About all you can count on with
many implementations is that the sequence is non-decreasing and
accurate to within a few hundred milliseconds. (That is, you need to
ignore the last two or three digits of the returned value.)
On Aug 18, 2005, at 6:26 AM, Peter wrote:
>
>
> * calls to System.currentTimeMillis() often returns the same
> value.
> I'm using the system time to synchronize animations, but the
> method isn't returning the correct values. Here are some values
> printed to the console during a loop:
>
> call number 0: 1124370216093
> call number 1: 1124370216140
> *call number 2: 1124370216218
> call number 3: 1124370216218*
> call number 4: 1124370216406
> *call number 5: 1124370216421
> call number 6: 1124370216421*
> call number 7: 1124370216625
> *call number 8: 1124370216718
> call number 9: 1124370216718*
> call number 10: 1124370216937
> *call number 11: 1124370217046
> call number 12: 1124370217046
> call number 13: 1124370217265
> call number 14: 1124370217265
>
> *
>
> It's worth noting that this is an actual game loop and so, between
> the calls, I'm doing a lot of calculations and method calls, so it's
> very strange that consecutive calls return the same value. Running the
> same loop on a Nokia 7210 emulator gives me some more accurate values:
>
>
> call number 0: 1124359929265
> call number 1: 1124359929343
> call number 2: 1124359929406
> call number 3: 1124359929468
> call number 4: 1124359929531
> call number 5: 1124359929593
> call number 6: 1124359929687
> call number 7: 1124359929750
> call number 8: 1124359929812
> call number 9: 1124359929875
> call number 10: 1124359929953
> call number 11: 1124359930015
> call number 12: 1124359930078
> call number 13: 1124359930140
> call number 14: 1124359930203
>
> In other words: calls to System.currentTimeMillis() shouldn't
> *ever*
> return the same values. Since it is returning strange values, it's
> hard
> to implement a good animation. Any ideas on how to solve or any
> workarounds for these problems?
>
> Peter
>
>
>
> This mail was sent to address EricHildum@earthlink.net
> Need archives? How to unsubscribe? http://www.appelsiini.net/keitai-l/
>
>
-- No attachments (even text) are allowed --
-- Type: application/pkcs7-signature
-- File: smime.p7s
Received on Sat Aug 20 19:38:08 2005