我正在使用此代码从actionPerformed上的按钮直接调用invokeLater:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
int temp = (jComboBox1.getSelectedIndex() + 1);
heavyProccesingFunction();
}
});
}
Run Code Online (Sandbox Code Playgroud)
这仍然冻结了GUI.为什么?我没有使用invokelater函数得到相同的结果.
我应该用
Thread queryThread = new Thread() {
public void run() {
Run Code Online (Sandbox Code Playgroud)
代替?
编辑:
谢谢,应该使用新的线程.