#include <thread>
#include <iostream>
void hello(){
std::cout << "Hello from thread " << std::endl;
}
int main(){
std::thread t1(hello);
t1.join();
return 0;
}
#include <thread>
#include <iostream>
#include <vector>
void hello(){
std::cout << "Hello from thread " << std::this_thread::get_id() << std::endl;
}
int main(){
std::vector<std::thread> threads;
for(int i = 0; i < 5; ++i){
threads.push_back(std::thread(hello));
}
for(auto& thread : threads){
thread.join();
}
return 0;
}
Hello from thread 140276650997504 Hello from thread 140276667782912 Hello from thread 140276659390208 Hello from thread 140276642604800 Hello from thread 140276676175616
Hello from thread Hello from thread Hello from thread 139810974787328Hello from thread 139810983180032Hello from thread 139810966394624 139810991572736 139810958001920
#include <thread>
#include <iostream>
#include <vector>
int main(){
std::vector<std::thread> threads;
for(int i = 0; i < 5; ++i){
threads.push_back(std::thread([](){
std::cout << "Hello from thread " << std::this_thread::get_id() << std::endl;
}));
}
for(auto& thread : threads){
thread.join();
}
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有