操作系统调度程序决定哪个线程获得对互斥锁的控制权—通常,等待时间最长的读线程先读取数据。
The operating system scheduler determines which thread gets control of the mutex next-typically, the reader thread that has waited the longest gets to read the data first.
因为添加和取出数据操作使用相同的互斥锁,所以读取数据的速度会影响写数据的线程访问锁。
Because you're sharing the same mutex for push and pop operations, the data-read speed is somewhat compromised as writer threads access the lock.
应用推荐