ITeye博客

23种设计模式之单例模式(Singleton)

lynnwoo · 2010-10-22 11:13 · 设计模式 · 编程语言 · Markdown

保证一个类仅有一个实例,并提供一个访问它的全局访问点


package org.example.patterns.singletonPattern;
/**
 * @author LY
 * @version 创建时间:Oct 22, 2010 11:14:20 AM
 * 类说明 : 单例模式
 */
public class Singleton {
	private static Singleton instance = null;
	
	public static synchronized Singleton getInstance (){
		return (instance == null) ? new Singleton(): instance;
	}
}


评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。