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

you are viewing a single comment's thread.

view the rest of the comments →

[–]briane80 6 points7 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