I am trying to update the UI from a callable, but fail.
Why is the System.out.println("UI thread."); never called?
I am using 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);
The Problem happened, because i executed the upper code in a JunitTest.
The test returned, before the async Runnable could could be executed.
Waiting at the end of the test – helped!