Is it safe to sync java.awt.Container.paint (Graphics g)?
I am using some 3rd party AWT components in a desktop application. The component's layout has been changed in the method paint()
and this causes very strange behavior. This seems to have been fixed by adding a keyword synchronized
to the paint () method, but is it safe to do so?
+2
a source to share
2 answers
It looks like the method paint()
is being called outside of the event dispatch thread , which can indeed cause very strange behavior, so this should never be done.
Instead, paint()
the application code should only callrepaint()
+3
a source to share