1
0
Fork 0
This repository has been archived on 2021-11-03. You can view files and clone it, but cannot push or open issues or pull requests.
uni-m.cds-adv-prog/ex9.1/c.cpp
Eric Teunis de Boone d9d2d5f18f Finished Ex9.*
2020-01-07 11:01:08 +01:00

34 lines
487 B
C++
Executable file

#include <thread>
#include <string>
#include <iostream>
#include <chrono>
/*
* Compile with 'g++ -pthread a.cpp'
*
* The order of printing is not well-defined
*/
using namespace std;
void f1() {
cout << "Hello " << endl;
this_thread::sleep_for(std::chrono::seconds(2));
cout << "World" << endl;
}
void f2() {
this_thread::sleep_for(std::chrono::seconds(1));
cout << "Parallel" << endl;
}
int main() {
thread t1(f1);
thread t2(f2);
t1.join();
t2.join();
return 0;
}