Singletons, Enums and anonymous inner classes

前端 未结 3 1392
梦毁少年i
梦毁少年i 2021-01-05 00:52

As you may know, some people are declaring singletons with an Enum of 1 instance, because the JVM guarantees that there will always be a single instance with no concurrency

3条回答
  •  自闭症患者
    2021-01-05 01:25

    Thus what about an Enum with multiple instances?

    There is no such thing, and your example doesn't demonstrate it. You have an Enum with multiple values. They are all singletons.

提交回复
热议问题