27 lines
364 B
C++
Executable file
27 lines
364 B
C++
Executable file
|
|
#include <thread>
|
|
#include <string>
|
|
#include <iostream>
|
|
|
|
/*
|
|
* Compile with 'g++ -pthread b.cpp'
|
|
*
|
|
* This gets an error 'terminate called without an active exception'
|
|
*/
|
|
|
|
using namespace std;
|
|
|
|
void f1() {
|
|
cout << "Hello ";
|
|
}
|
|
|
|
void f2(const std::string& s) {
|
|
cout << s << endl;
|
|
}
|
|
|
|
int main() {
|
|
thread t1(f1);
|
|
thread t2{f2, "Parallel World!"};
|
|
|
|
return 0;
|
|
}
|