在一个article的双重检查锁定成语,我发现这句话:
One special case of lazy initialization that does work as expected without synchronization is the static singleton. When the initialized object is a static field of a class with no other methods or fields,the JVM effectively performs lazy initialization automatically.
为什么强调部分很重要?如果有其他方法或领域,为什么它不起作用?
(这篇文章已经超过10年了.信息是否仍然相关?)
最佳答案