![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
多线程
文章平均质量分 58
阿呆不爱说话
学生
展开
-
多线程学习基础
C++11的标准库中提供了多线程库: 管理线程: #include <thread> thread th1; 函数 功能 thread() 创建线程函数:普通函数、类成员函数对象,lambda表达式 join 线程阻塞,等待子线程完成、汇合 detach 线程分离,失去线程所有权 joinable 检查是否还拥有线程所有权,true有,false无 get_id 获取线程id sleep_for 休眠 互斥: #include <mutex>原创 2021-11-07 16:48:41 · 455 阅读 · 0 评论 -
C++多线程学习
C++多线程-生产者和消费者 #include<iostream> #include<string> #include<thread> #include<mutex> #include<queue> #include<condition_variable> using namespace std; //缓冲区存储的数据类型 struct CacheData { //商品id int id; //商品属性 string原创 2021-11-07 13:40:04 · 246 阅读 · 0 评论