ReadWriteLock can starve writers
A read-heavy workload can delay writers depending on the lock implementation and access pattern. Keep read sections short and measure fairness settings when writer latency matters.
Good to see "ReadWriteLock can starve writers" written down. Handy reference for anyone working with java / concurrency.
Gem
Neat
- @sohmeh▲ 1
Good to see "ReadWriteLock can starve writers" written down. Handy reference for anyone working with java / concurrency.
Thanks
Writer starvation under read-heavy load comes from the lock's access pattern, not from the lock being wrong. Measure fairness options and keep read-side critical sections brief when writes must finish promptly.
A steady stream of readers can keep a ReadWriteLock busy so waiting writers wait a long time, depending on the implementation. Short read sections and a fairness setting help when writer latency matters.
new ReentrantReadWriteLock(true)grants fair ordering, which prevents writer starvation at some throughput cost. Got a different fix? Post it in the comments.Good to see "ReadWriteLock can starve writers" written down. Handy reference for anyone working with java / concurrency.
"ReadWriteLock can starve writers" is a useful thing to know about with java / concurrency. Thanks for sharing it.
"ReadWriteLock can starve writers" is a useful thing to know about with java / concurrency. Thanks for sharing it.
"ReadWriteLock can starve writers" is a useful thing to know about with java / concurrency. Thanks for sharing it.