使用boost.bind绑定class的成员函数作为boost thread的入口

来源:互联网 发布:远程连接软件 编辑:程序博客网 时间:2024/06/05 16:40
class HelloWorld{public:    void hello();    void entry();};void HelloWorld::hello() {     std::cout << "Hello world, I'm a thread!" << std::endl;}int main(int argc, char* argv[]) {     HelloWorld hw;    hw.entry();    return 0;}void HelloWorld::entry(){    boost::thread thrd(boost::bind(&HelloWorld::hello,this));    thrd.join();}