Singleton instantiation

前端 未结 10 1600
我寻月下人不归
我寻月下人不归 2020-12-05 05:40

Below show is the creation on the singleton object.

public class Map_en_US extends mapTree {

    private static Map_en_US m_instance;

    private Map_en_US         


        
10条回答
  •  一整个雨季
    2020-12-05 05:56

    Interesting never seen that before. Seems largely a style preference. I suppose one difference is: the static initialisation takes place at VM startup, rather than on first request for an instance, potentially eliminating an issue with concurrent instantiations? (Which can also be handled with synchronized getInstance() method declaration)

提交回复
热议问题