singleton

Singleton mode implementation method, 1: Private constructor, and then write a method to create a static object.

2 lazy mode, write a static final new (*); create an object. Private constructor.

3. Implemented by static inner class, it is optimal, has thread safety, and the guarantee mechanism is guaranteed by the classloader mechanism of jvm

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324620640&siteId=291194637