Debugging Swing Event Dispatch Thread Violations
DetectionThrough the hard work of Scott Delap and Alexander Potochkin it is now easy to find many Swing threading problems caused by making Swing calls from a thread other than the Event Dispatch Thread (EDT).
These are the three easy steps:
Alternatively, you can use SwingUtilities.invokeLater(). This will let the invoking thread continue to do other things. If the Runnable and the invoking thread are doing unrelated tasks in parallel, this is a good thing. However, if you later try to use the objects being used in the Runnable the access should be synchronized to ensure the EDT and your thread don't conflict.
Copyright © 2016 Andrew Oliver