偶遇 :org.eclipse.swt.SWTException: Failed to execute runnable
来源:互联网 发布:广州零点 数据分析 编辑:程序博客网 时间:2024/05/22 07:47
Exception in thread "main" org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)at org.eclipse.swt.SWT.error(SWT.java:4282)at org.eclipse.swt.SWT.error(SWT.java:4197)at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4140)at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3757)at demos.common.main(Launcher.java:125)Caused by: org.eclipse.swt.SWTException: Widget is disposedat org.eclipse.swt.SWT.error(SWT.java:4282)at org.eclipse.swt.SWT.error(SWT.java:4197)at org.eclipse.swt.SWT.error(SWT.java:4168)at org.eclipse.swt.widgets.Widget.error(Widget.java:468)at org.eclipse.swt.widgets.Widget.checkWidget(Widget.java:340)at org.eclipse.swt.widgets.Control.internal_new_GC(Control.java:1689)at org.eclipse.swt.graphics.GC.<init>(GC.java:166)at org.eclipse.swt.graphics.GC.<init>(GC.java:132)
SWT应用采用“左树右内容”的结构,左边是树菜单,通过点击树菜单,右边显示对应的内容,实现方式是,每点击树的叶子结点的时候,把右边容器的子容器全部dispose,然后再画上新的内容。
运行一段时间,发现,某个树节点对应的内容里面,如果包含有thread域,则在点击其它节点的时候,会报以上的异常,这种情况应该是在dispose右边容器的子窗口的时候,没把线程给灭掉,线程继续运行,这时就报错了。
经过调试,找到解决方法,在线程run方法里面加上一个判断,如果运行该线程的容器被dispose了,则不继续运行线程,如下所示:
public void run(){if(!composite.getParentControl().isDisposed()) { //do your things}}
加上以上判断,点击有thread变量的节点,再点击其它节点,不会报前面所说的Exception。
- 偶遇 :org.eclipse.swt.SWTException: Failed to execute runnable
- org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
- 使用eclipse时出错org.eclipse.swt.SWTException: Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)
- eclipse 启动失败,报错org.eclipse.swt.SWTException: Failed to execute runnable
- eclipse 启动失败,错误信息org.eclipse.swt.SWTException: Failed to execute runnable
- eclipse 启动失败,报错org.eclipse.swt.SWTException: Failed to execute runnable
- Failed to execute runnable (org.eclipse.swt.SWTException: Widget is disposed)原因以及解决办法
- org.eclipse.swt.SWTException: Invalid thread access
- SWT异常: org.eclipse.swt.SWTException: Invalid thread access
- SWT异常: org.eclipse.swt.SWTException: Invalid thread access
- SWT异常: org.eclipse.swt.SWTException: Invalid thread access
- SWT多线程异常--org.eclipse.swt.SWTException: Invalid thread access
- org.eclipse.swt.SWTException: Invalid thread access问题解决方法
- RCP中的org.eclipse.swt.SWTException: Invalid thread access 问题
- org.eclipse.swt.SWTException: Invalid thread access解法
- 解决 org.eclipse.swt.SWTException: Graphic is disposed 问题
- org.eclipse.e4.core.di.InjectionException:org.eclipse.swt.SWTException: Widget is disposed
- SWT部分组件的继承问题(引发错误:org.eclipse.swt.SWTException: Subclassing not allowed )
- 错误:expected initializer before"***"
- 使用javamail发送邮件
- 设计模式之对反射的理解
- Axure
- Asp.net下实现打印效果
- 偶遇 :org.eclipse.swt.SWTException: Failed to execute runnable
- java获取当前时间
- OpenNI不用标定获取人体骨架
- Lighttpd与PHP
- 流水的启示
- 自定义进程条
- Extjs4 颜色选择器 ColorField
- directshow应用开发的常用操作函数
- 利用javascript写的32位MD5加密算法