I know that it used to be considered safe to call repaint()
and a few other selected methods from any thread even with Swing\'s threading model, however I was r
As discussed in Painting in AWT and Swing: Paint Processing,
JComponent.repaint()
registers an asynchronous repaint request to the component'sRepaintManager
, which usesinvokeLater()
to queue aRunnable
to later process the request on the event dispatching thread.
This is a necessary, but not sufficient, condition to establish a happens-before relation between successive calls to repaint()
. As a practical matter, you still need to synchronize access to any data that is shared between threads. Without this, there's no way to ensure the visibility of any changes meant to influence the subsequent call to repaint()
.