EDT and other Thread relations regard repaint() method java

好久不见. 提交于 2019-12-24 06:58:33

问题


if the GUI was sure build by EDT does a repaint call on some other Thread invoke painting on the EDT? if not, how do i make sure it does, the more efficient the better.


回答1:


Basically method repaint() invoke EDT by default, everything works until first Thread.sleep(int) was called, then you have an issue with Concurency in Swing,

Have to look at Swing Timer, which providing basic funkcionalities for painting in the Swing or delaying any event(s) in the Swing GUI ,

If your update(s) isn't about Graphics then you can invoke EDT by wrapping output to the Swing GUI to the invokeLater()



来源:https://stackoverflow.com/questions/9289331/edt-and-other-thread-relations-regard-repaint-method-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!