0
点赞
收藏
分享

微信扫一扫

boost::thread_group简单使用


类似线程池,demo如下:

#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <iostream>
void fun(int i) {
std::cout << "fun:" << i << std::endl;
}
int main() {
boost::thread_group threads;
for (auto i = 0;i < 10;i++) {
threads.create_thread(boost::bind(fun, i));
}
threads.join_all();

return 0;
}

举报

相关推荐

0 条评论