cracking singleton with other ways

后端 未结 6 718
情深已故
情深已故 2020-12-07 05:20

I was doing research on singleton and I have developed a very basic singleton class..

public class SingletonObject {
    private static SingletonObject ref;
         


        
6条回答
  •  遥遥无期
    2020-12-07 05:52

    Via reflection, set ref = null. By re-assigning it as null, the logic to lazily construct the singleton will be triggered again on the next invocation of getSingletonObject.

提交回复
热议问题