c++ 并行:并行的一个小实验
作者:互联网
#include<iostream> #include<thread> void func1() { std::cout<<"%%%%%%%%%%%%%%%%%%%"<<std::endl; } void func2() { std::cout<<"$$$$$$$$$$$$$$$$$$$$$$"<<std::endl; } void func3() { std::cout<<"&&&&&&&&&&&&&&&&&&&&&&&"<<std::endl; } void func4() { std::cout<<"**********************"<<std::endl; } void func5() { std::thread t1(func1); std::thread t2(func2); t1.join(); t2.join(); } void func6() { std::thread t3(func3); std::thread t4(func4); t3.join(); t4.join(); } void func7() { std::thread t1(func1); std::thread t2(func2); t1.join(); t2.join(); } int main() { std::thread t5(func5); std::thread t6(func6); t5.join(); t6.join(); //func7(); return 0; }
cmakelist
cmake_minimum_required(VERSION 2.8) project(bingxing) find_package (Threads) add_executable(bingxing bingxing.cpp) target_link_libraries(bingxing ${CMAKE_THREAD_LIBS_INIT})
build文件
mkdir build cd build cmake .. make ./bingxing
结果:
&&&&&&&&&&&&&&&&&&&&&&& ********************** $$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%
标签:cmakelist,cmake,并行,c++,实验,build,bingxing,include 来源: https://www.cnblogs.com/polipolu/p/13325410.html