In java ArrayBlockingQueue
implementation, locking is always performed following way.
Main lock is declared as final variable in the source code which makes sense.
/** Main lock guarding all access */
final ReentrantLock lock;
and in method, in order to lock, it does following way.
final ReentrantLock lock = this.lock;
lock.lock();
What is the reasoning behind this and does general api user expects to do same style or is this for JDK specific special implementation?