您的位置:首页 > 其它

Thread(多线程,单例模式懒汉式)

2015-04-21 02:34 176 查看
package process;

//饿汉式
class Single{
private Single(){}
private static Single s = new Single();

public static Single getInstance(){
return s;
}

}
//懒汉式:双层判断
class Single1{
private Single1(){}
private static Single1 s = null;

public static Single1 getInstance(){
if(s == null){
synchronized(Single1.class){
if(s == null){
s = new Single1();
}
}
}
return s;

}
}
public class ThreadSingle {

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: