tags:

views:

37

answers:

1

I currently have code that makes a call from java into my cocoa app using JNI, in the JNI function on the cocoa side I create a new thread and assign my NSApp delegate like the main function would do. Here is the code I am using in a dummy class that creates my real class:

@implementation MenuLauncher 

- (void)run {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    [NSApplication sharedApplication];
    Menu *menu = [Menu sharedInstance];
    [NSApp setDelegate:menu];
    [NSApp run];
[pool release];
}

@end

This is a copy of what is in my main function only this is in a thread.

The result is the interface that Menu creates does not respond and only gives the spinny beach ball.

I am doing a simple sleep statement on the java side to keep the process alive. The cocoa gui should be running in it's own thread. So why is it frozen?

A: 

You may need to have the Cocoa code run on the main thread. Also, specifying the "-XstartOnFirstThread" flag to the java command might be needed (as it is for SWT applications).

mprudhom