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



In Java, create a Thread and an Object. Pass it through JNI to your native code, which grabs a reference to it and kicks off another thread, registers the thread with the JVM, and creates a CFRunLoop. The Java thread calls wait() on the object, so it blocks.

When the CFRunLoop gets notified via IOKit that the computer just woke up, it calls notify(). The original Java thread wakes up and then does whatever clock management needs to be done before it calls wait() on the object again to wait for the next sleep/wake cycle.

Eric,

Thanks for your reply -- this looked like an excellent strategy (much cleaner than my initial NSSelector approach), so I gave it a shot. Works like a charm.

For the sake of posterity, there's a tutorial page on calling Java from native methods at http://java.sun.com/docs/books/tutorial/native1.1/implementing/method.html

Thanks again,

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: 
 >JNI and NSSelector (From: "Nathan V. Roberts" <email@hidden>)
 >Re: JNI and NSSelector (From: Eric Albert <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.