设计模式
恩洛
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
代理模式
AOP底层,将一些与业务逻辑无关的共有操作分离1、静态代理public class ProxyPatternDemo { public static void main(String[] args) { Landlord landlord = new Landlord(); Agency agency = new Agency(landlord); agency.rent(); }}// 真实角色class Landlord implements Rent{ @Override原创 2021-02-28 17:34:56 · 151 阅读 · 0 评论 -
单例模式
1、饿汉式public class Hungry { // 私有化构造方法 private Hungry () {} // 初始化对象 private static Hungry hungry = new Hungry(); // 公开的获取对象的方法 public static Hungry getInstance() { return hungry; }}2、懒汉式2.1 单线程版本多线程不安全原因?多线程情况下,多个线程同时执行到 if(lazyMan ==null)语原创 2021-02-27 02:46:48 · 243 阅读 · 0 评论
分享