标签:cond include 编译 div 线程 fir ted ace col
1.多线程初次使用:
// thread example #include <iostream> #include <thread> using namespace std; void foo() { //do stuff } void bar(int x) { //do stuff } int main() { thread first (foo); //spawn new thread that calls foo() thread second (bar, 0); //spawn new thread that calls bar(0) cout << "main, foo and bar now execute concurrently...\n"; first.join(); second.join(); cout << "foo and bar completed.\n"; return 0; }
2.关于g++编译时候需要注意,不同g++版本可能不一样。
g++ thread.cpp -o thread -lpthread -std=c++11
标签:cond include 编译 div 线程 fir ted ace col
原文地址:https://www.cnblogs.com/Shinered/p/9061824.html