//私有化构造器
private DemoService(){}
private static DemoService service;
//提供静态方法
public static synchronized DemoService getInstance(){
if(service==null){
service = new DemoService();
}
return service;
}
单例模式示例
最新推荐文章于 2023-03-31 23:15:17 发布