我有一个无限的while循环,等待SwingUtilities.invokeLater
中带有Runnable
接口的事件,但执行没有继续......为什么?
//here hello3 prints in cmd but hello2 will not execute
System.out.println("hello3");
//showMessage();
SwingUtilities.invokeLater(
new Runnable(){
public void run() {
while(true) {
jEditorPane1.setText(s9);
}
}
}
);
System.out.println("hello2");
答案 0 :(得分:3)
SwingUtilities.invokeLater将在事件派发线程中执行run方法。
如果您向我们展示的所有代码都在事件派发线程中执行(例如,如果它在actionListener中执行),那么线程就会变得“冻结”#34;在无限循环中。