boost线程列表

boost thread list

本文关键字:列表 线程 boost      更新时间:2023-10-16

我有类似于下面的代码。下面的代码给出了SIGSEGV,并指向list::push_back。这是使用提升线程列表的正确方式吗?

struct mythread{
   static void myfunc() {
      while(1){ }
   }
};
int f(){
   std::list<boost::thread *> pool;
   pool.push_back(new boost::thread(mythread::myfunc));
}

环境:Ubuntu上的gcc 4.4.5,与libboost_thread.a和-lpthread链接。我没有使用c++0x标志。

问候,

Chubsdad

注2:我还得到了代码的SIGSEGV

pool.push_back(new boost::thread(NULL);

尝试获取函数指针的地址:

pool.push_back(new boost::thread(&mythread::myfunc));