标签:os io for cti 时间 amp c++ ios
#include<iostream>
#include<thread>
#include<vector>
#include<algorithm>
int main()
{
std::vector<std::thread> threadVec;
for(int i=0; i<5; ++i){
threadVec.push_back(std::thread([]()
{
std::cout<<"thread function\n";
}));
}
std::cout<<"main thread\n";
std::for_each(threadVec.begin(), threadVec.end(), [](std::thread & thr)
{
thr.join();
});
return 0;
} 运行结果为: for(int i=0; i<5; ++i){
threadVec.push_back(std::thread([i]()
{
std::cout<<"thread function "<<i <<"\n";
}));
}
std::cout<<"main thread\n"; 得到的结果是:C++11线程指南(二)--Lambda线程实现,布布扣,bubuko.com
标签:os io for cti 时间 amp c++ ios
原文地址:http://blog.csdn.net/shltsh/article/details/38393529