What should be the use cases for choosing between ReentrantLock and StampedLock? For example, Which lock should be chosen if I have 10 Readers and 10 Writers? And which one to choose if i have 20 Readers and 1 writers?
ReentrantLock
is, as its name and javadocs say, reentrant. StampedLock is not.
StampedLock is a low-level building block with some fragile behavior and complex interaction with the java memory model. Its use should be avoided unless you understand all its properties and have profiled code to determine that something is actually bottlenecked on locking.