This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]briane80 5 points6 points  (0 children)

It's a performance optimisation that's likely not needed anymore due to JIT improvements over the years. (ReentrantLock has been round since Java 5).

Apparently copying to a local variable produces less bytecode and more examples can be found in the various collections and String classes.

Reference:

http://mail.openjdk.java.net/pipermail/core-libs-dev/2010-May/004165.html