2020.02.16 懒汉式单例模式

package com.guoyun.ThreadTest;

/**
* ClassName:
* Function: ADD FUNCTION
* Reason: ADD REASON
*
* @author
* @Date
* @since Ver 1.1
*/
public class InstanceDemo {
private static InstanceDemo instance=null;
private InstanceDemo(){}
public static InstanceDemo getInstance(){
if (instance==null){
synchronized (InstanceDemo.class){
if (instance==null){
instance=new InstanceDemo();
}
}
}
return instance;

}
}
posted @ 2020-02-17 01:07  ByLir  阅读(113)  评论(0)    收藏  举报