Just curious what people do?
Rob Spoor wrote:For all code that I expect to run longer than a few milliseconds I use SwingWorker (most often), SecondaryLoop (used it once so far) or regular threads (just about never). The alternative is non-responsive user interfaces which is a definite no-no.
Using the "1 thread we started with" (the main thread) doesn't work since it continues and ends when the EDT thread is started. Threads in user interfaces usually are triggered by events by the users (like a button press), so you can't use the main thread unless you want to make it wait for jobs to execute. That makes your code unnecessarily complex though.
does the EDT thread start when you use Swing components, or when is it triggered?
I guess if you were to do something like a menu item it would run a separate thread and open?
Darryl Burke wrote:
does the EDT thread start when you use Swing components, or when is it triggered?
Any code wrapped in a SwingUtilities/EventQueue#invokeLater(...)/invokeAndWait(...) will kick off the EDT if it's not already started. Otherwise, the starting of the EDT is an implementation detail that you shouldn't need to worry about. My observations have been that the first construction of any Swing component starts the EDT. Not tested whether constructing an AWT component does the same.
I guess if you were to do something like a menu item it would run a separate thread and open?
Don't guess. Specify. All Swing and AWT event handling code executes on the EDT. If you need a different thread of execution, use one of the three techniques suggested by Rob Spoor.