在SWT程序中,SWT会自动创建一个用户界面线程,非用户界面线程不能直接操作用户界面线程,要想在另外一个线程中尝试访问或修改用户界面,应采用一下方法.
Thread t1=new Thread(){
public void run(){
try{
windowDisplayBar.getDisplay().syncExec(new Runnable(){
public void run(){
System.out.println("windowDisplayBar:"+windowDisplayBar);
}
});
}catch(Exception e){
e.printStackTrace();
}
}
};
总结一下也就是 SWT的在对其组件进行操作的时候有一个单线程的约束,直接的赋值方式是行不通的,SWT在*.widget.Display类中提供了两个方法可以间接的在非用户线程的进行图形构件的访问操作,这是通过异步启动新的线程的asyncExec(Runnable)和同步启动新的线程的syncExec(Runnable)两个方法去实现的。他们区别在于前者UI线程不会等待runnable对象执行结束后再继续进行,就是说UI线程可以和Runnable对象所在的线程同时运行,即无论指定的线程是否执行都会立即返回到当前线程;而后者则要在指定的等待runnable线程执行结束后才返回,比较耗时。
分享到:
相关推荐
NULL 博文链接:https://wilian.iteye.com/blog/1992365
Caused by: android.system.ErrnoException: write failed: ENOSPC (No space lef
解决 cvc-complex-type.2.4.d: Invalid content was found 具体参考http://henatne.iteye.com/blog/837186
Error creating bean with name 'org.springframework.web.servlet.handler.SimpleUrlHandlerMapping#0' defined in ServletContext resource [/WEB-INF/springMVC-servlet.xml]: Initialization of bean failed;...
invalid multibyte character sequence 870告警1
修复了MqttAndroidClient会出现throw new IllegalArgumentException Invalid ClientHandle报错,而源github中代码未更新解决,所以经过重新编译,生成新的jar包,增加IllegalArgumentException异常处理,替换关联的...
nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManagerBeanName' of bean class [org.springframework.transaction.interceptor....
大家可以直接使用 Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property ...
出现以上的情况主要的原因是因为在主配置文件标签没正确的指向映射接口的配置文件。 解决方案:1.检查的name是否正确,如我的name属性填的就是com.it.dao 2、检查的class属性或resource属性,我resource这里写的是...
STM32f10x系列的startup文件(.s文件),从例程代码里拿出来的,方便以后自己找。 ps.貌似必须收费至少1分啊。。。
Maven坐标:org.apache.yetus:audience-annotations:0.5.0; 标签:apache、yetus、audience、annotations、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
Maven坐标:org.apache.httpcomponents:httpcore:4.4.13; 标签:apache、httpcomponents、httpcore、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。...
再和前台对接的时候一直报错:invalid url domain 在网上查找了很多资料,有说端口的问题,也有其它各种原因的,一大堆,最后我发现以上的说法都不准确,这是我配置的地址(错误的地址) 把配置地址的http://去掉...
Neo4j Java Reference 3.0
Nginx常见的错误和解决方法,1、Nginx 常见...启动时如果报异常error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory 这说明我们的环境还不是和启动需要
UDK2018环境搭建所需步骤及安装包,VS请安装2015版本,请根据自己CPU的类型(amd, intel)选择所需的安装包搭建环境。
org.springframework.beans.NotWritablePropertyException: Invalid property 'URIType' of bean class [com.alibaba.citrus.service.uribroker.uri.GenericURIBroker]: Bean property 'URIType' is not writable ...
1、ValueError: Invalid control character at: line 1 column 8363 (char 8362) 使用json.loads(json_data)时,出现: ValueError: Invalid control character at: line 1 column 8363 (char 8362) 出现错误的...
AssertionError: Invalid device id 仔细检查后发现原来服务器有多个GPU,当时开启了两个进行加速运算。 net1 = nn.DataParallel(net1, device_ids=[0, 1]) 而本地台式机只有一个GPU,调用数量超出所以报错。 改为 ...
Dubbo管理控制台(兼容JDK8)