public class Singleton { private static volatile Singleton singleton; private Singleton() { } /** * 分配内存空间 * 初始化内存空间 * 将引用指向内存空间 * * 由于重排序,可能出现 1 -> 3 -> 2 * @return */ public static Singleton getSingleton() { if (singleton == null) { synchronized (Singl…