linux對C++11多線程的支持

#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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章