zoukankan
html css js c++ java
线程编程时,需要注意的
当进行线程编程时,需要注意的一些事情:
当使用Qt库互斥量的时候不要做任何阻塞操作。这将会冻结事件循环。
确认你锁定一个递归
QMutex
的次数和解锁的次数一样,不能多也不能少。
在调用除了Qt容器和工具类的任何东西之前锁定Qt应用程序互斥量。
谨防
隐含地共享
类,你应该避免在线程之间使用操作符=()来复制它们。这将会在Qt的未来主要的或次要的发行版本中进行改进。
谨防那些没有被设计为线程安全的Qt类,例如,
QPtrList
的应用程序接口就不是线程安全的并且如果不同的线程需要遍历一个QPtrList,它们应该在调用
QPtrList::first
()之前锁定并且在到达终点之后解锁,而不是在
QPtrList::next
()的前后进行锁定和解锁。
确认只在GUI线程中创建的继承和使用了
QWidget
、
QTimer
和
QSocketNotifier
的对象。在一些平台上,在某个不是GUI线程的线程中创建这样的对象将永远不会接受到底层窗口系统的事件。
和上面很相似,只在GUI线程中使用QNetwork类。一个经常被问到的问题是一个
QSocket
是否可以在多线程中使用。这不是必须得,因为所有的QNetwork类都是异步的。
不要在不是GUI线程的线程中试图调用processEvents()函数。这也包括
QDialog::exec
()、
QPopupMenu::exec
()、
QApplication::processEvents
()和其它一些。
在你的应用程序中,不要把普通的Qt库和支持线程的Qt库混合使用。这也就是说如果你的程序使用了支持线程的Qt库,你就不应该连接普通的Qt库、动态的载入普通Qt库或者动态地连接其它依赖普通Qt库的库或者插件。在一些系统上,这样做会导致Qt库中使用的静态数据变得不可靠了。
查看全文
相关阅读:
2020.4.13 机器学习相关数学基础
2020.3.30 机器学习概述
12.18语法制导的语义翻译
12.11算符优先分析
12.4自下而上语法分析
11.27实验二 递归下降语法分析
11.20LL(1)文法的判断,递归下降分析程序
11.13消除左递归
4.K均值算法--应用
3.K均值算法
原文地址:https://www.cnblogs.com/lvdongjie/p/5275352.html
最新文章
2019-2020-1学期 1924班小组《网络空间安全专业导论》小组讨论成果 组员:袁浩然 张纹豪 公凯文 张家华 马一
2019-2020-1学期 20192414《网络空间安全专业导论》第八周学习总结
学习小组讨论成果 组员:袁浩然 公凯文 马一 张家华 张纹豪
2019-2020-1学期 20192414《网络空间安全导论》第七周学习总结
201924班小组第六周讨论成果回报 组员 袁浩然 公凯文 张家华 马一 张纹豪
2019-2020-1学期20192414《网络空间安全导论》第六周学习报告
第五周小组讨论成果 组员:袁浩然 公凯文 张纹豪 马一 张家华
2019-2020-1学期 20192414《网络空间安全专业导论》第五周学习总结
ACM-ICPC 2018 徐州赛区网络预赛 B-BE, GE or NE
ACM Changchun 2015-E Rebuild
热门文章
ncpc2014-Clock Pictures
ncpc-2014 Catalan Square
HDU-6446Tree and Permutation
F-The Chosen One
I. Rake It In
CTU2107-H-Dark Ride with Monsters
F-The Best Path
E-Best Rational Approximation
2020.4.17 K均值算法--应用
2020.4.14 K均值算法
Copyright © 2011-2022 走看看