Java单例模式

package singleton;
/**
 * 单例模式
 * @author pengYi
 *
 */
public class Singleton {

	private static Singleton instance = null;
	
	private Singleton(){}
	
	public static Singleton getSingletonInstance(){
		if (instance == null) {
			instance =  new Singleton();
			return instance;
		} else {
			return instance;
		}	
	}
}

  

posted @ 2017-05-31 11:29  苦海无涯、苦尽甘来  阅读(156)  评论(0编辑  收藏  举报