摘要: 单件模式,又称单例模式 /** * 单例,版本一,此版本多线程下有问题。不要使用 */ public class Singleton00 { private Singleton00() { } private static Singleton00 uniqueInstance; public sta 阅读全文
posted @ 2021-07-06 21:33 htj10 阅读(65) 评论(0) 推荐(0) 编辑
摘要: 同步代码块,是锁这个对象 synchronized (this){...} 同步实例方法,也是锁这个对象 public synchronized void fun1(){ ... } 相当于将方法里的所有语句用synchronized (this){}包裹 public void fun1(){ s 阅读全文
posted @ 2021-07-06 15:23 htj10 阅读(50) 评论(0) 推荐(0) 编辑
TOP