- 浏览: 746703 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (419)
- 杂软粉墨 (2)
- 创意灵感 (3)
- 经验记录 (137)
- 开源轨迹 (2)
- sip-communicator (2)
- 闲侃杂谈 (8)
- 问题交流 (24)
- 概念模式 (32)
- 难点备案 (5)
- JwChat (1)
- 中国象棋 (1)
- 教育探索 (6)
- 英语研究 (58)
- 星际争霸 (1)
- 电信知识 (1)
- 软件架构 (3)
- 哲学探索 (26)
- 算法灵魂 (8)
- 近视探索 (6)
- 数学数学 (3)
- 牛角钻尖 (23)
- 至强文言 (3)
- 数据结构 (1)
- 宇宙物理 (2)
- 网络架构 (3)
- 游戏领域 (4)
- 图形处理 (2)
- 修炼之路 (8)
- 读书天地 (20)
- 编解乱码 (2)
- 概念探索 (8)
- 格物致知 (1)
- 其它语言 (1)
- 测试领域 (3)
- 文化风流 (1)
- JQuery (1)
- 網頁領域 (1)
- Unix/Linux (1)
- Inside JVM (1)
- 异常分析 (1)
最新评论
-
suyujie:
引用
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
suyujie:
HTML <a> 标签灰显禁用 -
iamzhoug37:
您能说一下"局部变量不受文本顺序限制" 是 ...
声明前为什么能赋值却不能输出,都是使用
SWT中初学者不经意会碰到这个异常,有时候很明确是创建多个Display对象引起的,但是为什么呢?
If a listener has a large amount of work to perform, instead of performing that work in the UI-thread, it can fork a separate thread so the UI-thread can continue dispatching events. If the other thread needs to execute code that accesses an SWT object, such as changing the string in a label, there is a concurrency issue. At the very least, some kind of synchronization is necessary to prevent the operating system or SWT from crashing, hanging or behaving unpredictably.
SWT implements a single-threaded UI model often called apartment threading. In this model, only the UI-thread can invoke UI operations. SWT strictly enforces this rule. If you try and access an SWT object from outside the UI-thread, you get the exception "org.eclipse.swt.SWTException: Invalid thread access". Different operating systems have different rules governing threads, UI components and synchronization. Some use a single-threaded UI model like SWT. Others allow only one thread at a time in the window system library, controlling access through a global lock. This type of multi-threaded UI model is often called free threading. Currently, in order to be simple, efficient and portable, SWT is apartment threaded.
To allow background threads to perform operations on objects belonging to the UI-thread, the methods syncExec(Runnable runnable) and asyncExec(Runnable runnable) of Display are used. These are the only methods in SWT that can be called from any thread. They allow a runnable to be executed by the UI-thread, either synchronously, causing the background thread to wait for the runnable to finish, or asynchronously allowing the background thread to continue execution without waiting for the result. A runnable that is executed using syncExec() most closely matches the equivalent direct call to the UI operation because a Java method call always waits for the result before proceeding, just like syncExec().
The following code sets the text of a label from a background thread and waits for the operation to complete:
display.syncExec( new Runnable() { public void run(){ label.setText(text); } });
在建立swt的程序时一般总是只需要一个display对象。但也有特别的情况,有的平台不支持swt创建多个活动的display对象。也就是说,如果 已存在一个display对象,但是给它没有发送disose()消息来销毁它,有的平台是不支持再创建一个新的display对象。
SWT实现的是单线程UI模型,在这个模型里,只有UI线程(创建首个Display对象的线程)才能调用UI操作,如果从UI线程外访问SWT对象就会 得到异常"org.eclipse.swt.SWTException: Invalid thread access".
但我想重复new Display对象也未必和多线程挂得上勾,查看Display源码及一些资料,应该基于所创建新Display对象之线程已经存在的判断:
if (Displays [i].thread == thread) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS);
发表评论
-
关于方法访问控制符protected
2012-11-29 10:38 1261http://bbs.csdn.net/topics/3902 ... -
一个基本问题关于引用的
2012-05-15 10:20 1126问: int a = 1; Integer b = new ... -
我對面向對象和過程的理解。
2012-05-02 08:30 1065我的一些理解。 面向过程,是对客观现象的描述,感觉是有一个上 ... -
stack and heap
2012-01-13 23:17 1050我觉得是根据应用方式 和本身特性 才将内存分区的,目的是提 ... -
program experience conclusion
2011-07-11 15:35 10621. check parameters for validit ... -
PreparedStatement's possible designated parameter
2011-04-29 13:45 985though it's nearly impossible t ... -
clean Log4j
2011-04-12 11:19 1065import org.apache.log4j.BasicCo ... -
about abstract class
2011-04-02 10:34 866yes, we do know abstract class ... -
cvs operations on linux
2011-03-25 09:40 1009http://www.linuxhowtos.org/Syst ... -
regex to exchange two parts
2011-03-24 17:09 1087public class Test { public ... -
About the database locking
2011-03-09 11:02 962http://en.wikipedia.org/wiki/Lo ... -
how to send soap message in java
2011-03-08 10:29 1894import java.io.BufferedReader; ... -
About ShutDownDemo
2011-03-07 15:02 980public class ShutdownDemo { p ... -
How do you know if an explicit object casting is needed
2011-02-24 16:33 1186通俗来讲,不可能将一只是猫的动物强转为狗 再说Graphic ... -
有关MimeUtility
2011-02-24 13:11 3360import java.io.UnsupportedEncod ... -
C#连接sql server 2008的一件2事
2011-02-24 09:01 2151once upon a time, i came upon o ... -
Shadowing, Overriding, Hiding and Obscuring
2011-02-22 15:15 1163当子类属性与父类属性重叠时 这种叫法上是shadowi ... -
JAXP usage
2011-02-16 16:07 1096import java.io.ByteArrayInputSt ... -
运行一个类,如果classpath中路径带空格就加双引号
2011-02-11 11:25 2805注意是这样加: java -cp .;"d:\my ... -
关于ClassPath中的current directory
2011-01-28 16:40 1152Given: 1. package com.company. ...
相关推荐
Android的MQTT消息推送接收所需jar包,修复了MqttAndroidClient会出现throw new IllegalArgumentException Invalid ClientHandle...implementation files('libs/org.eclipse.paho.android.service-1.1.1-sources.jar')
NULL 博文链接:https://wilian.iteye.com/blog/1992365
找到eclipse安装目录的features,将其目录中的org.sonatype.m2e.mavenarchiver.feature_0.NNN文件夹删除(也可能不存在),拷贝features/org.sonatype.m2e.mavenarchiver.feature_0.17.2.201609252051到features ...
在XML Schema设计中,"cvc-complex-type.2.4.d: Invalid content was found" 是一个常见的错误信息,这通常意味着在解析XML文档时,遇到了不符合定义的复杂类型的内容。这个错误通常涉及到XML Schema的约束规则,即...
Invalid Multibyte Character Sequence 警告解析 在编程中,特别是在嵌入式系统开发中,我们经常会遇到Invalid Multibyte Character Sequence 警告。这个警告通常来自于编译器,告知我们存在非法的多字节字符序列。...
### 错误解析:Caused by: android.system.ErrnoException: write failed: ENOSPC (No space left 在Android开发过程中,可能会遇到“Caused by: android.system.ErrnoException: write failed: ENOSPC (No space ...
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;...
Maven坐标:org.apache.httpcomponents:httpclient:4.5.12; 标签:apache、httpcomponents、httpclient、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档...
nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'transactionManagerBeanName' of bean class [org.springframework.transaction.interceptor....
### 发送邮件的基础知识与实现方法 #### 一、SMTP简介 SMTP,即简单邮件传输协议(Simple Mail Transfer Protocol),是一种用于从源地址到目的地址传输邮件的标准协议。通过SMTP,我们可以控制邮件在网络中的传递...
Maven坐标:org.apache.yetus:audience-annotations:0.5.0; 标签:apache、yetus、audience、annotations、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览...
- **确保文件保存为UTF-8编码**:这是最常用的文本编码格式之一,可以有效避免因编码不兼容而导致的解析失败。 - 可以通过文本编辑器的保存选项设置编码方式。 #### 4. 检查空格和特殊字符 - **确保没有不必要的...
java.lang.IllegalStateException: Invalid name=“com.alibaba.dubbo.config.ProtocolConfig#0” contains illegal character, only digit, letter, ‘-’, ‘_’ or ‘.’ is legal 原因: 如果没有指定id属性,...
bcprov-jdk15on-***.jar中文文档.zip,java,bcprov-jdk15on-***.jar,org.bouncycastle,bcprov-jdk15on,***,jar包,Maven,第三方jar包,组件,开源组件,第三方组件,Gradle,bouncycastle,bcprov,jdk15on,中文API文档,手册,...
大家可以直接使用 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这里写的是...
在使用Mybatis框架时,你可能会遇到`org.apache.ibatis.exceptions.PersistenceException`这样的异常。这个异常通常表示在执行数据库查询操作时遇到了问题。本篇将详细分析这个问题并提供解决方法。 ### 问题概述 ...
Maven坐标:org.apache.httpcomponents:httpcore:4.4.13; 标签:apache、httpcomponents、httpcore、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。...
10. **`"upstream sent invalid header while reading response header from upstream"`**:后端服务器发送的响应头部无效。 11. **`"client intended to send too large body"`**:客户端发送的数据体超过了配置的...
STM32F10x系列是意法半导体(STMicroelectronics)推出的基于ARM Cortex-M3内核的微控制器,广泛应用于各种嵌入式系统设计。`STM32F10x_startup`指的是针对该系列芯片的启动文件,通常以`.s`格式存在,它是微控制器...