阅读背景:

140_多线程(多线程-单例设计模式-懒汉式)

来源:互联网 

/*
单例设计模式

饿汉式
class Single{
	private static final Single s = new Single();
	private Single(){}
	public static Single getInstance(){
		return s;
	}
}

懒汉式
class Single{
	private static Single s = null;
	private Single(){}
	public static Single getInstance(){
		if(s==null){
			synchronized(single.class){
				if(s==null)
					s =  new Single();
			}
		}
		return s;
	}
}
*//*
单例设计模式

饿汉式
class Single{
	private static 




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: