How to instantiate a Singleton multiple times?

后端 未结 9 1872
醉酒成梦
醉酒成梦 2020-12-19 04:08

I need a singleton in my code. I implemented it in Java and it works well. The reason I did it, is to ensure that in a mulitple environment, there is only one instance of th

9条回答
  •  遥遥无期
    2020-12-19 04:56

    First, why do you need to create a new singleton to run a unit test? A unit test should not be running concurrently with the normal application, so you should be able to access the original singleton without fear of modifying it..

    Is there a particular reason you need an explicit second singleton?

提交回复
热议问题