PHP
·
发表于 5年以前
·
阅读量:8279
#include<iostream>
#include<thread>
using namespace std;
void thread1() {
for(int i=0;i<20;++i)
cout << "thread1..." << endl;
}
void thread2() {
for (int i = 0; i<20; ++i)
cout << "thread2..." << endl;
}
int main(int argc, char* argv[]) {
thread th1(thread1); //实例化一个线程对象th1,该线程开始执行
thread th2(thread2);
cout << "main..." << endl;
return 0;
}