Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Turning off -XstartOnFirstThread

On 9/8/08 3:37 PM, "Michael Franz" <mvfranz@xxxxxxxxx> wrote:

> Should OpenJDK understand this flag?  Or should another way of conveying the
> same information be used (I am not sure what the purpose of this flag is).

All UI code in either Carbon or Cocoa must happen on Thread 0 of the
application. That affects the architectures of the AWT and SWT on OS X.

Normally, for a lot of technical reasons I won¹t go into here, the Java VM
gathers up the arguments passed to /usr/bin/java, and spawns a new thread
that invokes the JNI necessary to start the Java VM. If it didn¹t do this,
the application would hang when loading the AWT.

For similar reasons, the SWT must run its readAndDispatch loop on thread 0,
or none of the widgets will work. They may show up, but user events won¹t be
delivered to them.

Since the AWT is the Œtypical¹ use case, the JVM always loads the VM on a
non-main thread unless you tell it otherwise. That¹s what
­XstartOnMainThread does. It invokes all of the JNI VM startup code on
thread 0.

If you want to follow up, we can discuss it more in the bug.

Scott



Back to the top