public void run() {
try {
display = Display.getDefault();
- display.setRuntimeExceptionHandler((e) -> e.printStackTrace());
- display.setErrorHandler((e) -> e.printStackTrace());
-
- while (!shutdown) {
- if (!display.readAndDispatch())
- display.sleep();
+ boolean displayOwner = display.getThread() == this;
+ if (displayOwner) {
+ display.setRuntimeExceptionHandler((e) -> e.printStackTrace());
+ display.setErrorHandler((e) -> e.printStackTrace());
+
+ while (!shutdown) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ display.dispose();
+ display = null;
}
- display.dispose();
- display = null;
} catch (UnsatisfiedLinkError e) {
logger.log(Level.ERROR,
"Cannot load SWT, either because the SWT DLLs are no in the java.library.path,"
}
}
+ @Deprecated
public Display getDisplay() {
return display;
}