The ImageJ Launcher uses pthread_create and CFRunLoopSourceCreate to start the JVM on a dedicated thread:
/* MacOSX needs to run Java in a new thread, AppKit in the main thread. */
static void dummy_call_back(void *info) { }
...
pthread_t thread;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/* Start the thread that we will start the JVM on. */
pthread_create(&thread, &attr, start_ij_aux, NULL);
pthread_attr_destroy(&attr);
CFRunLoopSourceContext context;
memset(&context, 0, sizeof(context));
context.perform = &dummy_call_back;
CFRunLoopSourceRef ref = CFRunLoopSourceCreate(NULL, 0, &context);
CFRunLoopAddSource (CFRunLoopGetCurrent(), ref, kCFRunLoopCommonModes);
CFRunLoopRun();
The ImageJ Launcher uses
pthread_create
andCFRunLoopSourceCreate
to start the JVM on a dedicated thread:Should Jaunch also do this?