我正在了解C++11中的线程,我做了一些尝试来创建一个新的线程。
#include <iostream>
#include <thread>
using namespace std;
void doSomething() { cout << "Inside doSomething " << endl; }
void doSomethingElse() { cout << "Inside doSomethingElse " << endl; }
int main(void)
{
// Using LAMBDA expressions to call the functions.
thread my_thread([](){ doSomething(); doSomethingElse(); });
//my_thread.join(); ---------------> 1
return 0;
}
我尝试执行代码,但没有调用my_thread.join()
,Visual Studio 2013报错“abort()已被调用”。
原因是什么?