Is Initialization On Demand Holder idiom thread safe without a final modifier
问题 I have a hunch that using the holder idiom without declaring the holder field as final is not thread safe (due to the way immutability works in Java). Can somebody confirm this (hopefully with some sources)? public class Something { private long answer = 1; private Something() { answer += 10; answer += 10; } public int getAnswer() { return answer; } private static class LazyHolder { // notice no final private static Something INSTANCE = new Something(); } public static Something getInstance()