Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: intermittent hang on launch



Rolf Howarth wrote:

Not that it's worth getting overly pedantic over such a trivial point, but constructing, packing and showing my main frame from within main() is a pattern I have followed for years and years and years without problem. Indeed, it's explicitly declared to be safe by Sun "An application's GUI can often be constructed and shown in the main thread", see http://java.sun.com/products/jfc/tsc/articles/ threads/threads1.html

The only caveat is that this has to be the FIRST bit of GUI code in your application. After you have created and shown any components and the event loop comes into existence then it's no longer safe. But if all you're doing is creating and showing a single frame then it's perfectly safe.


I don't think this is trivial at all. The Sun web page you are citing is several years outdated. During this time, Sun has changed the recommendations about whow to create GUI elements; they now suggest that everything (including the app frame creation) is done in the event thread. Many many examples on the web and in books still do things differently.

Our experience with Java apps over the past years has been that doing _everything_ Gui related in the event threat is becoming more and more important. We had "dirty" apps that accessed Gui elements from different threads which worked fine for years, but eventually became unstable. Moving Gui stuff the event thread seemed to solve the problem.

We are currently trying to find the cause of an intermittent Java launch problem on Windows. I think it may be well be related to some Gui stuff left outside the event thread. It was put there because it's slow preparation stuff, and does not actually show any Gui elements. It has run fine like this for years. Now we are getting occasional problem reports, but only on XP Pro and 2003 server (although rare similar problems may occur on some OS X machines). Impossible to reproduce and track down; no error or crash logs, and installing debug versions of the launcher usually makes the problem go away. I have a hunch that this may be a result of the better threading and multi-CPU support on these OS versions, which leads to a higher likelihood of thread deadlocks.

--
Peter Richterich
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: intermittent hang on launch (From: Rolf Howarth <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.