请问在boost::thread_group中,我如何获取每个子线程任务的返回值?
boost版本:1.79.0
操作系统版本:Windows11
编译器:VS2022
没懂,你是要区分子线程?
#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;
}