我正在尝试从可调用更新 UI,但失败了。为什么System.out.println("UI thread.");
从未调用?我正在使用 SWT。
Callable<Boolean> callable = new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
System.out.println("Executing Callable.");
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
System.out.println("UI thread.");
}
});
System.out.println("End.");
return true;
}
};
ExecutorService executor = Executors.newFixedThreadPool(10);
executor.submit(callable);