Udi*_*shi 2 java concurrency user-interface swing multithreading
我用非常简单的线程(延迟1秒)制作简单的游戏,线程出现问题,我有while(true)代码循环:
try {
    while (true) {
       Ltimer.setText(getTimeElapsed());
       Thread.currentThread();
       Thread.sleep(1000); // Thread sleeping for 1 second           
    }
} catch (Exception e) {
    JOptionPane.showMessageDialog(null, "error with timer");       
} 
它只是每隔一秒就得到一个字符串并在我试图运行gui freeze时更新标签文本,我只能看到黑色背景中的标签,所有按钮和bg img消失了.试图解决 
 setVisible()
repaint()
但没有得到任何东西..
还有其他选择吗?