CentOS7下无法编译thread多线程
CentOS7下无法编译thread多线程
#include <iostream>
#include <thread>
#include <chrono>
#include <mutex>
using namespace std;
mutex m_mutex;
void func()
{
lock_guard<mutex> lock(m_mutex);
for(int i = 0; i < 10; i++)
{
cout << "线程" << this_thread::get_id() << "执行任务" << i << endl;
this_thread::sleep_for(chrono::seconds(1));
}
}
int main()
{
thread t1(func);
t1.join();
return 0;
}