类的非静态成员函数做boost::thread参数
来源:互联网 发布:java 二进制流 编辑:程序博客网 时间:2024/04/30 21:18
http://bbs.csdn.net/topics/80329092
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>#include <iostream>
using namespace std;
class Count
{
public:
Count();
void addCount();
void getCount();
void mainThread();
void print(int i);
private:
typedef boost::mutex::scoped_lock slock;
boost::mutex mutex;//for count
//boost::condition cond;
int count;
};
Count::Count()
{
this->count = 0;
}
void Count::addCount()
{
slock lock(this->mutex);
while(1)
{
this->count++;
}
}
void Count::getCount()
{
slock lock(this->mutex);
this->print(this->count);
}
void Count::mainThread()
{
boost::thread thrd1(boost::bind(&Count::addCount, this));
thrd1.join();
}
void Count::print(int i)
{
cout<<i<<endl;
}
int main()
{
Count object;
object.mainThread();
return 0;
}
0 0
- 类的非静态成员函数做boost::thread参数
- boost thread 使用类的非静态成员函数做线程函数之【原理】
- 实现类非静态成员函数做窗口过程函数
- 类成员函数参数为该类某个静态成员函数指针,需要在静态函数内使用当前实例的非静态数据成员
- 关于编译器对c++ 类静态成员、静态成员函数、非静态成员函数的处理
- 静态成员函数和非静态成员函数的区别?
- 静态成员函数和非静态成员函数的区别?
- 静态成员函数和非静态成员函数的区别
- 静态成员函数与非静态成员函数的区别
- 类的非静态成员函数作为线程函数
- 静态成员函数如何调用非静态成员变量(函数参数不能任意扩展的情况)
- 线程的静态函数如何访问类的非静态成员函数或成员变量
- C++的静态成员函数访问非静态成员变量
- 类中的静态成员函数访问非静态成员变量
- 如何输出类的非静态成员函数地址
- 如何输出类的非静态成员函数地址
- 如何输出类的非静态成员函数地址
- 如何输出类的非静态成员函数地址
- hdu1072
- list view特殊属性
- E20-007数据科学及大数据分析的认证考试概况
- E20-007数据科学及大数据分析概述考试
- 百度员工离职总结:如何做个好员工?(都是大实话 )
- 类的非静态成员函数做boost::thread参数
- JDeveloper 更改JDevRuntime位置
- 【Leetcode长征系列】Sort Colors
- ubuntu (Kubuntu) PATH相关脚本启动顺序
- cocos2dx中供类使用的一些宏
- 在Laravel中一步一步创建Packages
- 玩转Bash脚本:test测试语句
- 约瑟夫问题算法
- 2473 HDU Junk-Mail Filter [并查集+设立虚父节点(马甲)]