| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
At 17:38 -0500 31/1/07, Peter Richterich wrote:
>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
>...
>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.
There's no argument that in general it's a really bad idea to update
your GUI (including the model) from anything other than the event
dispatch thread. It might work ok, most of the time, in one
implementation and fail completely in another. We're talking about
the specific case of instantiating the main app frame though.
It probably depends on what you're in the habit of doing in your
frame constructor. If you call pack or show, display a dialog, or
create new threads which might themselves update your model or any
GUI components then you may encounter problems, but those aren't
things I would normally ever do in a frame constructor.
I'd be very surprised indeed if code which just created components,
added them to the frame, and registered listeners would then cause a
subsequent call to pack() and show() from the main thread to deadlock
or otherwise be unstable. If it did, huge numbers of existing Java
applications would break and it would be reasonable to consider it a
JVM bug.
-Rolf
--
Rolf Howarth
Square Box Systems Ltd
Stratford-upon-Avon UK.
http://www.squarebox.co.uk
_______________________________________________
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
_______________________________________________ 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: Peter Richterich <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.