検索すると大別すると3個あるという情報がHITするけど、今はstd::threadが一番良いと思う。なおC#ではスレッドではなくTask(TPL)を使う。C++でもPPLがあるけど移植性低下するし使いにくいのでstd::threadがよさげ。
[include]
#include
std::thread
void process() {
//...
}
int main() {
int i = 0;
std::thread t1(process); // 別スレッドでprocessの処理を行う
std::thread t2([&i](int x) {
int counter = 0;
while(counter++ < x) {
i += counter;
}
}, 10); // 関数オブジェクトの引数に10を渡す
t1.detach(); //スレッドt1の管理を放棄
t2.join(); //スレッドt2の処理が終了するまで待機
std::cout << i << std::endl;
}
[参考]
http://kaworu.jpn.org/cpp/std::thread
メモ:[std::async]
C#でおなじみのasync/awaitはもうじきC++で普及しそう。
VS2013にパッチあてると使えたと思うけど、無料版のVS2015だと使えなかった。