标签:执行 _id nbsp thread this 完成 join std bsp
#include <thread> #include <cstdio> #include <utility> #include <iostream> void print(int x) { printf("%d\n", x); } int main() { std::thread t1(print, 1); std::thread t2(print, 2); // 获得线程ID std::thread::id t1_id = t1.get_id(); std::thread::id t2_id = t2.get_id(); std::cout << t1_id << " " << t2_id << std::endl; /* * 阻塞当前线程,直至 *this 所标识的线程完成其执行。 * *this 所标识的线程的完成同步于从 join() 的成功返回。 */ t1.join(); t2.join(); return 0; }
标签:执行 _id nbsp thread this 完成 join std bsp
原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/10230851.html