#include <thread>
#include <iostream>
#include <mutex>
#include <condition_variable>
std::mutex data_mutex;
std::condition_variable data_var;
bool flag=true;
int i=1;
#define MAXNUM 10
void printA(){
//i=9时就结束循环
while(i<MAXNUM){
std::this_thread::sleep_for(std::chrono::seconds(1)); //打印节奏变慢
std::unique_lock<std::mutex
C++多线程交替打印1-100
最新推荐文章于 2023-04-02 00:24:50 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)