我有一个无限 while 循环等待 SwingUtilities.invokeLater
中具有 Runnable
接口(interface)的事件,但执行没有继续...为什么?
//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");
最佳答案
SwingUtilities.invokeLater 将在事件调度线程内执行 run 方法。
如果您向我们展示的所有代码都在事件调度线程内执行(例如,如果在 actionListener 内执行),则线程将在无限循环内“卡住”。
关于java - SwingUtilities.invokeLater 无限循环,不继续?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36821266/