int main() {
std::thread t1(foo); // start thread that prints "foo" forever
t1.join(); // wait for thread to complete, it never does
std::thread t2(goo);
t2.join();
}
How can i start thread 2?
To get a multi threading program?
By allowing your program to continue to the line that starts it. Currently, you're preventing that from happening by telling your program to wait for a thread to finish, when that thread can never finish.
Do you understand why this is happening?
EDIT: Also, please use code tags when posting code, to make it readable:
By allowing your program to continue to the line that starts it. Currently, you're preventing that from happening by telling your program to wait for a thread to finish, when that thread can never finish.
Do you understand why this is happening?
I understand the idea behind it
My goal is that the first thread writes data from buffer to hard disk (every second).
The second thread should write new data into the buffer.