Possible Duplicate:
In ArrayBlockingQueue, why copy final member field into local final variable?
Check out this code from ThreadPoolExecutor:
private final ReentrantLock mainLock = new ReentrantLock();
...
private void ensureQueuedTaskHandled(Runnable command) {
final ReentrantLock mainLock = this.mainLock;
mainLock.lock();
Why is this.mainLock
copied to a local variable?
I know this pattern is useful to ensure the field doesn't change, but we're talking about a final field here. Is it still relevant?