摘要: file: BlockQueue.hpp: #pragma once #include<pthread.h> #include<cassert> #include<queue> const int maxsize=5; template<class T> class BlockQueue{ publ 阅读全文
posted @ 2025-11-03 21:46 xdhking 阅读(7) 评论(0) 推荐(0)
摘要: 概念 1.多个执行流进行安全访问的共享资源——临界资源 2.多个执行流中,访问临界资源的代码——临界区--往往是线程代码的很小一部分 3.想让多个线程串行访问共享资源——互斥 4.对一个资源进行访问的时候,要么不做,要么做完——原子性 解决方案: 解决方案:加锁 互斥锁pthread_mutex_t 阅读全文
posted @ 2025-11-03 15:28 xdhking 阅读(17) 评论(0) 推荐(0)