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 - Solved



I think I have this working right, now. It was a deadlock, caused by some sloppy programming. We did not run our app in a thread, as recommended, and we got bitten.

The solution is pretty much what Doug Zwick and Ulrich Kortenkamp recommended, using a main() kind of like this:

public static void main(final String[] args) {
SwingUtilities.invokeLater (new Runnable() { public void run() { runMyApp(args); } });
}

or this:

public static void main(final String[] args) {
Thread t = new Thread("MyAppThread") { public void run() { runMyApp(args); } };
try { javax.swing.SwingUtilities.invokeLater(t); }
catch (Exception e) { e.printStackTrace(); }
}
where runMyApp(String[] args) looks like this:

private static void runMyApp(String[] args) {
app = new MyApp(); // does initializations
try { app.run(args); } // run it
catch(Exception e) { e.printStackTrace(); } // reports bad stuff
}

We had some of our initializations in the run method, and some in the constructor. Bad.
 _______________________________________________
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



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.