Question

Currently, my entire gui has to freeze while the database connection is established. So instead, I wanted to run the connection in a background thread/task, and then tell the user when the connection has been established.

Should I use a SwingWorker or a normal Thread or something else of the kind?

Was it helpful?

Solution

Should I use a SwingWorker or a normal Thread or something else of the kind?

SwingWorker would be the optimal way, since it ensures that updates to the GUI are performed on the Event Dispatch Thread. Having said that, it is also possible to use a Thread, just so long as you ensure the GUI is updated on the EDT.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top