Updating visible components from other threads is the source of many common bugs in Java programs that use Swing.
This means GIT is a shared data structure and some synchronization is needed to ensure that only one thread accesses it at a time.
[2][3][4] Since programmers often miss this requirement, third-party Look and Feels, like Substance go as far as to refuse to instantiate any Swing component when not running within the Event Dispatch Thread,[5] to prevent such a coding mistake.
Both execution of a task in another thread and presenting the results in the EDT can be combined by means of worker design pattern.
The javax.swing.SwingWorker class, developed by Sun Microsystems, is an implementation of the worker design pattern, and as of Java 6 is part of standard Swing distribution.
SwingWorker is normally invoked from EDT-executed event Listener to perform a lengthy task in order not to block the EDT.
Then you can write it more simply like this: SwingWorker is normally created for a lengthy tasks by EDT while handling callback (Listener) events.
You see, this takes time (user responds in matter of seconds) and you need a responsive GUI (the messages are still pumped in EDT) during all this time while EDT is blocking (it does not handle newer, e.g. JFileChooser, messages in the queue before the dialog is closed and current component action is finished).