我使用以下代码从 actionPerformed 上的按钮直接调用 invokeLater:
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
int temp = (jComboBox1.getSelectedIndex() + 1);
heavyProccesingFunction();
}
});
}
这仍然会冻结 GUI。为什么?不使用invokelater函数我得到相同的结果。
我应该使用
Thread queryThread = new Thread() {
public void run() {
反而?
编辑:
谢谢,应该使用新线程。