//私有化构造器
private DemoService(){}
private static DemoService service;
//提供静态方法
public static synchronized DemoService getInstance(){
if(service==null){
service = new DemoService();
}
return service;
}
单例模式示例
最新推荐文章于 2025-05-27 22:14:43 发布
1641

被折叠的 条评论
为什么被折叠?



