Thread safe singleton
thread-safe, singleton

Synchornized

Single check lock

Performance issue

Double check lock

Drawback

Singleton can be destroyed by reflection

Final and Static

Enum & Interface

Creation of enum is guaranteed to be thread safe. All interface variables are implicitly modified with final and static, so they are thread safe.

drawback

Initialized when first loaded

Static helper class

http://www.journaldev.com/1377/java-singleton-design-pattern-best-practices-examples#thread-safe-singleton

Jian Wang /
« Optimize Java File Encoding Convert »