How does the ReentrantLock perform against synchronized for a solely uncontended lock acquisition ?
Suppose you intend to implement a two lock class (which means you need 2 different locks and synchronized would not suffice, like that in LinkedBlockingQueue) where in the acquisition of put and take locks are done by say thread1 and thread 2 (always), which means the locks are uncontended and the principle of thread locality comes in, how does the ReentrantLock perform against synchronized(which would entail complete locking of the queue) ?
Mostly ReentrantLock wins when 3 or more threads contends, but it depends on hardware, OS, JVM version and its options.
Martin Thompson published findings about ReentrantLock vs. synchronized block and biased locking in his blog:
http://mechanical-sympathy.blogspot.com/2011/11/java-lock-implementations.html
http://mechanical-sympathy.blogspot.com/2011/11/biased-locking-osr-and-benchmarking-fun.html