我正在尝试使用线程创建一个数组。我的代码如下所示:
boost::thread threads[10];
for(int i = 0; i < 10; i++){
client c(io_services[i], "www.boost.org", "/");
threads[i] ( boost::bind(workerFunc, i) );
}
我收到编译错误:
error: no match for call to ‘(boost::thread) (boost::_bi::bind_t<void, void (*)(int), boost::_bi::list1<boost::_bi::value<int> > >)’
threads[i] ( boost::bind(workerFunc, i) );
我无法弄清楚我的代码中需要更改的内容。任何帮助将不胜感激。
答案 0 :(得分:6)
您正在寻找:
boost::thread threads[10];
for(int i = 0; i < 10; i++){
client c(io_services[i], "www.boost.org", "/");
threads[i] = boost::thread( boost::bind(workerFunc, i) );
}