Implementing Singleton in Java

前端 未结 2 1714
执念已碎
执念已碎 2021-01-01 03:18

Please note that I have gone through the below thread :

What is an efficient way to implement a singleton pattern in Java?

To summarize, there are important

2条回答
  •  死守一世寂寞
    2021-01-01 03:22

    by glancing at the code (I will look at it more thoroughly hopefully later):

    2 is protected because you can't create multiple instances of an enumerated value. INSTANCE is written out...and so when you read it back in, you just cannot create another instance of INSTANCE if it exists. Nice feature of the language :).

提交回复
热议问题