Reputation: 2285
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?
Upvotes: 1
Views: 313
Reputation: 40256
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.
Upvotes: 1
Reputation: 118593
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.
Upvotes: 1