mercredi 2 mars 2016

Why does this C++ thread code trigger an abort() error?

I am testing the new C++11 thread features. To do this, I start a thread by providing a lambda expression to its constructor:

   int main()
    {
        thread t([]() {
            cout << "Hello World!" << endl;
        });

        //this_thread::sleep_for(chrono::seconds(5));

        cout << "I am done!" << endl;
        getchar();
        return 0;
    }

But after I press a key (getchar), I get the error:

Debug

Can someone give a reason?

Aucun commentaire:

Enregistrer un commentaire