Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/131.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/multithreading/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 增强线程列表_C++_Multithreading_List_Boost - Fatal编程技术网

C++ 增强线程列表

C++ 增强线程列表,c++,multithreading,list,boost,C++,Multithreading,List,Boost,我有类似于下面的代码。下面的代码给出了SIGSEGV并指向list::push_back。这是使用boost线程列表的正确方法吗 struct mythread{ static void myfunc() { while(1){ } } }; int f(){ std::list<boost::thread *> pool; pool.push_back(new boost::thread(mythread::myfunc)); } 尝试获取函

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

struct mythread{
   static void myfunc() {
      while(1){ }
   }
};

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

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

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

堆栈跟踪是什么样子的?list::push_back calls list::_M_插入哪些调用_list_node_base::hook。SIGSEGV来自钩子成员函数nope。没有帮助。我又撞车了,糟了。我刚刚试着在我的机器(g++4.4.1,ubuntu 9.10)上编译了你的代码,修改后的代码没有出现错误。老实说,我不能说我知道发生了什么。
pool.push_back(new boost::thread(&mythread::myfunc));