I've read java doc: ReentrantReadWriteLock
And I don't see that writeLock has any priority over readLock
But also I've read topics like this: Are read and write locks in ReentrantReadWriteLock somehow related?
and I see there in both answers following phrases:
if lock is held by readers and thread request write lock no more readers are allowed to acquire read lock until thread which has acquired write lock release it.
Prefers writers over readers. That is, if a writer is waiting on the lock, no new readers from other thread are allowed to access the resource. Existing readers can continue to use the resource until they release the lock. This prevents so-called "writer starvation".
And these phrases sounds meaningfully and looks like I've already read it somewhere else.
But obviously it is a contradiction with java doc.
Was it changed in latest JDK ? is it still valid ?
How to prevent writer starvation ?