Did I get it right? EDT is the main thread of GUI. To start a long operation, it's preferred to run it in new thread. So why do we need to use EventQueue for that? Why can't we simply create and run new thread just like in non-Swing programs?
Asked
Active
Viewed 309 times
2 Answers
1
There is nothing that says you need to use the EventQueue if you are running a long running operation in the background. The purpose of the queue here is to utilize if you have to update the UI that the long running process is complete.
When the process is complete you would put some kind of runnable notification on the Event Queue to notify the UI of completion.

John Vint
- 39,695
- 7
- 78
- 108
1
No, the EDT is essentially running on the main thread implicitly. You don't "move" the EDT. Rather, if you want to work off of the main thread, and off of the EDT, you do as you say and start your own thread.
Take a look at SwingWorker. It's a common mechanism to help facilitate this.

Will Hartung
- 115,893
- 19
- 128
- 203
-
See also [Initial Threads](http://download.oracle.com/javase/tutorial/uiswing/concurrency/initial.html). The initial thread doesn't _start_ the EDT, but it should schedule GUI creation on the EDT. – trashgod Apr 25 '11 at 17:45