Java Singleton vs static - is there a real performance benefit?

前端 未结 7 2016
抹茶落季
抹茶落季 2021-02-04 06:46

I am merging a CVS branch and one of the larger changes is the replacement wherever it occurs of a Singleton pattern with abstract classes that have a static initialisation bloc

7条回答
  •  清酒与你
    2021-02-04 07:11

    I would use a singleton if it needed to store any state, and static classes otherwise. There's no point in instantiating something, even a single instance, unless it needs to store something.

提交回复
热议问题