您好,我在C++ 11中遇到线程问题.我有使用g ++ 4.8.1的ubuntu 64bit 13.10(测试).我试着编译代码:
#include <thread>
void func()
{
// do some work
}
int main()
{
std::thread t(func);
t.join();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
带选项:-std = c ++ 11 -pthread -lpthread.编译成功,但当我尝试运行它时,我收到一个错误:
在抛出'std :: system_error'的实例后调用terminate
():启用多线程以使用std :: thread:不允许操作