Answer the question
In order to leave comments, you need to log in
When to use RWMutex instead of Mutex?
Hello!
I can not master RWMutex.
Can you give an example of a situation when you need to use RWMutex, and not a regular mutex?
You can even give the code of a super simple example, when a simple Mutex does not solve the problem.
Answer the question
In order to leave comments, you need to log in
In the case of an ordinary mutex, only exclusive access to the resource is possible, i.e. only one thread has read or write access.
And when we have RWMutex, then the number of threads when reading is unlimited, but when accessing for writing, access again becomes exclusive for only one thread.
RWMutex is used to increase throughput when the resource is accessed more frequently for reading than for writing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question