读到师兄的一篇博客,关于Java中的单件类模式,这么写的:
class Singleton {
private static Singleton instance;
// thread-safe singleton.
public static synchronized Singleton getInstance() {
if (instance == null)
instance == new Singleton();
return instance;[......]