Exception in thread "Timer-0" org.eclipse.swt.SWTException: Invalid thread access
在一个线程之中调用SWT控件的方法,报了现面的错误:
Exceptionin thread "Timer-0"org.eclipse.swt.SWTException:Invalid thread access
atorg.eclipse.swt.SWT.error(SWT.java:4282)
atorg.eclipse.swt.SWT.error(SWT.java:4197)
atorg.eclipse.swt.SWT.error(SWT.java:4168)
atorg.eclipse.swt.widgets.Widget.error(Widget.java:466)
atorg.eclipse.swt.widgets.Widget.checkWidget(Widget.java:404)
atorg.eclipse.swt.widgets.Control.forceFocus(Control.java:2307)
atcom.css.kingstudio.embeddedfirefox.views.BrowserView$2.run(BrowserView.java:135)
atjava.util.TimerThread.mainLoop(Timer.java:512)
atjava.util.TimerThread.run(Timer.java:462)
解决方法:在下面的run方法中完成SWT控件的调用:
display.syncExec(newRunnable() {
@Override
publicvoidrun() {
//swtmethod
}
});