我有一個無限的while循環等待SwingUtilities.invokeLater
與Runnable
接口的事件,但執行沒有繼續...爲什麼?SwingUtilities.invokeLater無限循環,而不是繼續?
//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");
從[併發中的Swing]開始(http://docs.oracle.com/javase/tutorial/uiswing/concurrency/)。你正在阻止美國東部時間。 'invokeLater'在將來的某個時間點在EDT上執行'Runnable'方法 – MadProgrammer