读书人

设计方式 之 单例模式

发布时间: 2012-10-16 09:57:37 作者: rapoo

设计模式 之 单例模式
对于单例模式, 我就举一个代码例子,

这个代码例子还是有问题的:
public static Singleton getInstance() {
if(singleton == null) {
synchronized(Singleton.class) {
if(singleton == null) {
singleton = new Singleton();
}
}
}
return singleton;
}

读书人网 >软件开发

热点推荐