I have a problem including the thread library. The following code:
#include <string>
#include <iostream>
#include <thread>
using namespace std;
//The function we want to make the thread run.
void task1(string msg)
{
cout << "task1 says: " << msg;
}
int main()
{
// Constructs the new thread and runs it. Does not block execution.
thread t1(task1, "Hello");
//Makes the main thread wait for the new thread to finish execution, therefore blocks its own execution.
t1.join();
}
Produces these errors:
The code is taken from the answer to another stackoverflow question. I am fairly new to codeblocks and C++ so please explain to me what I am doing wrong.