0

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?

HRgiger
  • 2,750
  • 26
  • 37
jong
  • 1
  • You can find answer here: http://stackoverflow.com/questions/2785964/in-arrayblockingqueue-why-copy-final-member-field-into-local-final-variable – shizhz Mar 26 '17 at 14:32
  • ah thanks you very much. I should have searched harder... – jong Mar 26 '17 at 14:35

0 Answers0