请问在boost::thread_group中,我如何获取每个子线程任务的返回值?
boost版本:1.79.0
操作系统版本:Windows11
编译器:VS2022
如何获取boost::thread_group返回值?
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
元气少女缘结神 2023-02-28 10:22关注没懂,你是要区分子线程?
#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; }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录