C++ 增强线程列表
我有类似于下面的代码。下面的代码给出了SIGSEGV并指向list::push_back。这是使用boost线程列表的正确方法吗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)); } 尝试获取函
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));