thread
  • 板块灌水区
  • 楼主exdfs
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/12/3 17:08
  • 上次更新2024/12/3 20:15:45
查看原帖
thread
949949
exdfs楼主2024/12/3 17:08

为什么会出现这种输出

2$
 3
4
5
6
7
8
9
10

代码:

#include<bits/stdc++.h>
inline void f(int a){ std::cout<<a<<"\n"; }
int main(){
    std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr);
    std::thread th[15];
    for(int i=1;i<=10;i++) th[i]=std::thread(f,i);
    for(int i=1;i<=10;i++){
        th[i].join();
    }
    return 0;
}
2024/12/3 17:08
加载中...