c – 如何停止/中断boost :: thread?
发布时间:2020-12-16 05:54:50 所属栏目:百科 来源:网络整理
导读:我在一个函数中创建一个线程,在另一个函数中,我想停止这个线程. 我试过这样的: class Server{private: boost::thread* mPtrThread;...public: void createNewThread() { boost::thread t(...); mPtrThread = t; } void stopThread() { mPtrThread-interrupt
我在一个函数中创建一个线程,在另一个函数中,我想停止这个线程.
我试过这样的: class Server { private: boost::thread* mPtrThread; ... public: void createNewThread() { boost::thread t(...); mPtrThread = &t; } void stopThread() { mPtrThread->interrupt(); } } 但这不是工作.我如何能阻止线程? 解决方法
如果要使用interrupt(),应该定义
interruption points.一旦达到中断点之一,调用interrupt()就会中断线程.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- react-native – React Native ListView – rowHasChanged不
- ruby-on-rails – 使用Twitter Bootstrap和Cocoon的Tab链接
- react-native – 有没有办法知道ReactNative中的组件是否在
- Cocos2dx------2048游戏
- Rman备份等级及备份脚本
- 基于XML配置的Spring MVC(所需jar包,web.xml配置,处理器
- 字符串和日期的相互转换,在oracle和mysql的用法
- 正则表达式必知必会
- Selector、动画之xml
- ruby-on-rails – Factory Girl与现有对象创建关联