I have been reading about using static objects as locks and the most common example would be something like this:
public class MyClass1 {
private static final Object lock = new Object();
public MyClass1() {
//unsync
synchronized(lock) {
//sync
}
//unsync
}
}
My question is does lock have to be final? I understand it is good to put it as final to assure that nobody messes with the value, but will it work without final?