标签:blog io ar div sp log on c ad
1 normal mode
class Singleton { private Singleton(){}; Singleton singleton; static Singleton getInstance() { if(singleton == null) singleton = new Singleton(); return singleton; } }
not thread safe.
Thread safe version:
class Singleton { static private Singleton(){}; Singleton singleton; static Singleton getInstance() { if(singleton == null) singleton = new Singleton(); return singleton; } }
标签:blog io ar div sp log on c ad
原文地址:http://www.cnblogs.com/williamwood/p/3977925.html