In Brian Goetz's book, Java Concurrency in Practice, his example of a Reentrant lock is programmed like this:
Lock lock = new ReentrantLock();
However, I am curious to know if changing the above code to:
private static final Lock lock = new ReentrantLock();
causes the lock to now act as a mutex, or if it is unnecessary and redundant.
Thus, does the functionality of this code change if the lock is made private, static, and final?
lock.lock();
try {
//method stuff
} finally {
lock.unlock();
}
Thank you all in advance. Matt