#include <thread>
#include <iostream>using namespace std;void func()
{cout << "子线程func开始执行!" << endl;//do somethingcout << "子线程func执行结束!" << endl;
}int main()
{cout << "主线程main开始执行!" << endl;thread t(func);t.detach();cout << "主线程main执行结束!" << endl;return 0;
}
参考:https://www.cnblogs.com/chen-cs/p/13056713.html
https://www.cnblogs.com/vivian187/p/12706081.html