-XstartOnFirstThread for OS X

Mike Swingler swingler at apple.com
Tue Dec 2 18:10:12 PST 2008

On Nov 26, 2008, at 8:19 PM, Michael Franz wrote:

> Hi,
> I have been thinking about this and have not come up with a way for  
> SWT to actually put their runloop on thread 0.  It is easy enough to  
> start the JVM on thread 0 but that prevents the changing of the  
> stack size, at least this is true on linux/solaris.

That is true. When we do -XstartOnFirstThread for the SWT, it cannot  
change the stack size of thread 0, but it is a hard requirement of Mac  
OS X that events are pumped from thread 0.

> Is it good enough to just have the JVM start on the first thread and  
> then lose the ability to change the JVM's stack size?

By design, it is simply the way it must be.

> What I have found interesting is that on Leopard using Apple's JDK5  
> they spit out a message about setting up for SWT when - 
> XstartOnFirstThread is passed, but this prevents any Swing  
> application from working.  This does not happen on Tiger with JDK 5.

Swing stops working, because -XstartOnFirstThread implies that that  
someone else (very likely the SWT) is going to come around, and start  
pumping the event loop on thread 0 with CFRunLoop or the like. It is  
possible that your testing on Tiger did not actually invoke the - 
XstartOnFirstThread behavior - we probably relied on other out-of-band  
information (like environment variables) at the time, or your version  
of Java was not the latest (it has been a very long time, so I'm not  
sure what the exact issue on Tiger might be).

Mike Swingler
Java Runtime Engineer
Apple Inc.

More information about the bsd-port-dev mailing list