Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JNI and NSSelector



At 11:17 AM -0700 10/4/02, Greg Guerin wrote:
"Nathan V. Roberts" <email@hidden>

I have a Java Cocoa app, a timer, that depends on the system clock
>(System.currentTimeMillis()). It happens that when you awake from
sleep, for the first few seconds (about 10 on my 400 MHz Pismo), the
>clock is in the past -- it ticks from the time it was put to sleep.
>And, then, suddenly, it jumps. This is just a display issue, unless
the user starts or stops the timer while the clock is in the past: if
starts, the timer will tick normally for a few seconds and then
>(possibly after the user has obscured my app) both clock and timer
will jump, possibly hours or days depending on the length of sleep.
If the user stops the timer, the timer will not jump with the clock,
>and so will be short by the amount of time the clock jumps.

Wouldn't it be simpler to just avoid System.currentTimeMillis() entirely,
and use a different time-base that doesn't jump? Don't "beat around the
bush" of the problem, go straight to the root of it.

Greg,

Thanks for your suggestion. My impression, both from my own tests and from reading up a bit in the cocoa list archives (Chris Kane had a very illuminating post), is that all the calendar clocks jump. And they jump (based on my tests) at exactly the time that IOKit posts the wake notification. Chris's post indicated that the kernel clock might not jump. Correct me if I'm wrong on this, but wouldn't the kernel clock get reset on restart? I definitely want to be able to continue timing across boots. Maybe I could figure some sort of tweak for this, but I doubt it'd be any less complex than my current strategy. So it seems to me that here the root of the problem is somewhat diffuse. (I did submit a bug report to Apple.)

I have the callbacks working thanks to Eric's response; all that's left to do is the, ahem, skip protection, so I'm going to stick with the System.currentTimeMillis() strategy.

Thanks!

Nathan
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Be sure to read the FAQ http://developer.apple.com/java/faq/ before posting
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: JNI and NSSelector (From: Greg Guerin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.