public class SWTThread implements IThreadWorkQueue, Executor {
- final Display display;
+ private final Display display;
+ private final boolean executeAsync;
+
+ public static IThreadWorkQueue getThreadAccess(Display display, boolean executeAsync)
+ {
+ return new SWTThread(display, executeAsync);
+ }
public static IThreadWorkQueue getThreadAccess(Display display)
{
- return new SWTThread(display);
+ return getThreadAccess(display, false);
}
public static IThreadWorkQueue getThreadAccess(Widget widget)
{
- return new SWTThread(widget.getDisplay());
+ return new SWTThread(widget.getDisplay(), false);
}
public static IThreadWorkQueue getThreadAccess() {
- return new SWTThread(Display.getDefault());
+ return new SWTThread(Display.getDefault(), false);
}
- SWTThread(Display display)
+ SWTThread(Display display, boolean executeAsync)
{
this.display = display;
+ this.executeAsync = executeAsync;
}
@Override
@Override
public void execute(Runnable command) {
- syncExec(command);
+ if (executeAsync) asyncExec(command);
+ else syncExec(command);
}
}