//懒汉模式 class Single { public static Single s = null; public Single (){} public static Single getInstance(){ if (s == null) { synchronized (Single.class){ if (s == null){ s = new Single (); } } } return s; } } 懒汉模式 (单利模式)在多线程下是不安全的,因此要加一个同步锁,锁对象用的是该类所…