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

前端 未结 7 2041
抹茶落季
抹茶落季 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:21

    Does this discussion help? (I don't know if it's taboo to link to another programming forum, but I'd rather not just quote the whole discussion =) )

    Sun Discussion on this subject

    The verdict seems to be that it doesn't make enough of a difference to matter in most cases, though technically the static methods are more efficient.

提交回复
热议问题