#include <stdio.h>
#include <unistd.h>
#include <thread>
using namespace std;
const int threadNum = 1000;
int test = 5;
void add(){
test++;
}
int main(){
thread thread_id[threadNum];
for(int i=0;i<threadNum;i++){
thread_id[i] = thread(add);
}
for(int i=0;i<threadNum;i++){
thread_id[i].join();
}
printf("%d
",test);
return 0;
}
运行了很多遍,结果都是1005呢
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…