您的位置:首页 > 其它

一个线程创建之初是没有消息队列的

2012-03-19 10:23 281 查看
昨天帮人改一个程序,由于不知道以下的内容,走了很多弯路。。。

原文可以在msdn中搜索“About Messages and Message Queues ”找到:

The system maintains a single system message queue and one thread-specific message queue for each graphical user interface (GUI) thread. To avoid the overhead of creating a message queue for non–GUI threads, all threads are created initially without a message queue. The system creates a thread-specific message queue only when the thread makes its first call to one of the User or Windows Graphics Device Interface (GDI) functions.

windows维护着一个系统消息队列,以及分别为每个GUI线程维护一个各自的线程消息队列。为了避免非GUI线程的创建线程消息队列的开销,所有线程创建初始化时,均不创建消息队列。只有当线程第一次调用GDI函数时,系统才会为线程创建消息队列。所以那些非GUI线程是没有消息队列的。

关于消息队列更多的解释可以在如下地址找到(文章是从msdn翻译过来的):

http://blog.csdn.net/bichenggui/article/details/4677494
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐