#include <iostream>
#include <thread>
#include <future>
using namespace std;
double calc(double v)
{
cout << "calc: " << std::endl;
cout << this_thread::get_id();
return 1.0;
}
int main()
{
thread t(calc, 30.0);
t.join();
cout << "Hello World!" << endl;
return 0;
}
編譯:1.cpp
g++ 1.cpp -std=c++11 -pthread