QThread 好象无法暂停(睡眠),然后再恢复(唤醒)?

Jonix 2013-02-13 02:05:10
QThread 好象自身无法暂停(睡眠),然后再恢复(唤醒)?

只能重新创建一个 QThread 对象?

有什么更直接的简单办法吗?
...全文
867 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
meiky 2013-02-18
  • 打赏
  • 举报
回复
有的, pImageThread->terminate();//线程中止 pImageThread->wait();//中止的线程并不能立即停止,等待期完全中止 pImageThread->start();//重新启动线程
乔巴好萌 2013-02-14
  • 打赏
  • 举报
回复
The QWaitCondition class provides a condition variable for synchronizing threads. QWaitCondition allows a thread to tell other threads that some sort of condition has been met. One or many threads can block waiting for a QWaitCondition to set a condition with wakeOne() or wakeAll(). Use wakeOne() to wake one randomly selected condition or wakeAll() to wake them all. 我猜测Qt之所以不使用resume和suspend多少是因为参考了java里的Thread的resume和suspend(java里这2个方法已经不被建议使用了-deprected),使用resume和suspend有“死锁倾向”
Jonix 2013-02-13
  • 打赏
  • 举报
回复
引用 1 楼 heksn 的回复:
QThread::sleep
不不不,我的意思是线程完全不工作,等我需要唤醒它的时候再重新开始
  • 打赏
  • 举报
回复
QThread::sleep

16,233

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧