仅读取共享内存时互斥锁

仅读取共享内存时互斥锁

问题描述:

我的印象是正确的,如果任何线程仅读取而不写入线程之间的共享内存,则不需要互斥保护吗?

Is my impression correct that if shared memory between threads is only read and never written, by any of the threads, mutex protection is unneccessary?

这是因为无论线程被抢占在何处,在重新调度线程后它总是可以再次起飞,并且内存内容不会更改.

It's because wherever a thread is preempted, it can always take off again when rescheduled, and the memory contents would not have changed.

是的,是的,读取同一变量的多个线程不会引起竞争.

Yes, you're right, multiple threads reading the same variable do not introduce a race.