ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## std::thread 生成多个 ``` #include <functional> #include <iostream> #include <thread> #include <vector> int main() { std::vector<std::thread> t; std::function<void()> f = []() { std::cout << "hello \n"; }; for (int i = 0; i < 10; ++i) { t.push_back(std::thread(f)); } for (auto &thread : t) { thread.join(); } return 0; } ```