タグ

ブックマーク / fjnl.hatenadiary.org (1)

  • C++11時代のthreading - fjnlの生存記録のような何か

    始めに 記事は C++11 Advent Calendar 2011 : ATND の6日目です。 std::thread C++11時代のthreadの基は std::thread です。おもむろに #include をしましょう。std::threadはコンストラクタで渡された関数オブジェクトを別スレッドで実行します。 #include <iostream> #include <thread> void f() { std::cout << "f()" << std::endl; } int main() { std::thread thr(f); thr.join(); return 0; } このプログラムを実行すると f() と表示されるはずです。コンパイルして実行してみます。 $ g++ -o thr thr.cpp -std=c++0x $ ./thr f() $ 確かに

    C++11時代のthreading - fjnlの生存記録のような何か
    nharuki
    nharuki 2012/12/18
    標準スレッドクラス利用方法まとめ
  • 1