Reputation: 1130
I am fairly new to Advanced Java and learning Reentrant locks. I understand that ReentrantLock has a fairness parameter which makes sure that the lock is given to most starving thread (unlike the case in synchronized intrinsic locks.)
However, Reentrant also means that the same thread can reacquire the lock again and again by incrementing the holdCount. If the same thread keeps acquiring lock forever how does it guarantee fairness?
Upvotes: 3
Views: 452
Reputation: 2083
If the thread reenters the lock, it means it hasn't ever unlocked it to leave a fair chance to other threads. Fairness is upon election of the next thread when the lock is not held.
Upvotes: 5