boost thread list
I have code开发者_JS百科 similar to below. The code below gives SIGSEGV and points to list::push_back. Is this the right way to use list of boost threads?
struct mythread{
static void myfunc() {
while(1){ }
}
};
int f(){
std::list<boost::thread *> pool;
pool.push_back(new boost::thread(mythread::myfunc));
}
Environment: gcc 4.4.5 on Ubuntu, linked with libboost_thread.a and -lpthread. I am not using c++0x flag.
Regards,
Chubsdad
Note 2: I also get SIGSEGV for the code
pool.push_back(new boost::thread(NULL);
Try taking the address of the function pointer:
pool.push_back(new boost::thread(&mythread::myfunc));
精彩评论