Question

I understand that we use SwingWorker background task to avoid blocking UI. When I have a long-running task that has to block the UI, is there any difference to make it run in event dispatcher thread or worker thread?

I see examples that runs a task with SwingWorker, and blocks the UI with a modal ProgressMonitor. Since UI has to be blocked, can the task (though takes time) run in event dispatcher thread?

Was it helpful?

Solution

There is a huge difference between disabling the UI elements (or making them unavailable by covering them up with a glass pane and a progress monitor) and futzing up your EDT with a long running task.

For instance, you won't be able to update the progress monitor, since this will usually require an automatic repaint submitted to the EDT that it won't be able to process until the task ends.

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