Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If you are working on a native function or method, please take a moment to determine which of the following behaviors describe it:

1) Only called on AppKit thread

Use AWT_ASSERT_APPKIT_THREAD; (defined in ThreadUtilities.h)

2) Only NOT called on AppKit thread

Use AWT_ASSERT_NOT_APPKIT_THREAD; (defined in ThreadUtilities.h)

3) Called on any thread

Make sure any shared data (instance variables or global data) is accessed only as an atomic property, or behind a lock that will not block for an indefinite period of time.

...

The JavaNativeFoundation.framework's JNFRunLoop class was born out of the necessity for both app developers who use JNI as well as JDK hackers to efficiently perform blocks of code on the main AppKit thread, while running in this special mode. JNFRunLoop.h exposes both an Obj-C selector and blocks-based API for performing with and without waiting:

Code Block
titleJNFRunLoop.h
/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaNativeFoundation.framework/Headers/JNFRunLoop.h