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;
		}	
	}
}

  

原文地址:https://www.cnblogs.com/py1994/p/6923303.html