In solving reader write problem, I try to use ReentrantReadWriteLock
. I know that all readers can acquire the read lock at the same time, however, write lock has to be wait for all the read locks to be released. Will this cause the writer to be in the starvation state if we have a lot of readers?
ReentrantReadWriteLock can be constructed with a fairness policy. If the flag is true, then there won't be starvation, however if it's false, it's possible there could be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With