In ArrayBlockingQueue
, all the methods that require the lock copy it to a local final
variable before calling lock()
.
This thread gives some answers. In substance:
It's an extreme optimization Doug Lea, the author of the class, likes to use. Here's a post on a recent thread on the core-libs-dev mailing list about this exact subject which answers your question pretty well.
from the post:
...copying to locals produces the smallest bytecode, and for low-level code it's nice to write code that's a little closer to the machine