Singleton pattern interview

前端 未结 8 2188
忘了有多久
忘了有多久 2021-02-04 14:26

I am recently asked about java related question in an interview with following code, since I am very new to java and barely code in Java so I really have no idea what the follow

8条回答
  •  不知归路
    2021-02-04 14:33

    Interviewer basically wants to check your knoweldge of Singleton pattern . Can the pattern be broken?. Ans is Yes. Check this or google - when singleton is not a singleton.

    Best course is to use Enum based Singleton as suggested by Joshua Bloch

提交回复
热议问题