#include <thread>
#include <iostream>
using namespace std;
void func()
{
cout << "子线程func开始执行!" << endl;
//do something
cout << "子线程func执行结束!" << endl;
}
int main()
{
cout << "主线程main开始执行!" << endl;
thread t(func);
t.detach();
cout << "主线程main执行结束!" << endl;
return 0;
}
c++ thread detach
最新推荐文章于 2024-06-14 10:34:50 发布