实现单例,从加载方式来看,有两种: 预加载 懒加载 先看一下实现单例最简单的方式(预加载): public class Foo { private static final Foo INSTANCE = new Foo(); private Foo() { if (INSTANCE != null) { throw new IllegalStateException("Already instantiated"); } } public static Foo getInstance() { return INSTANCE; } } 1234567891011121314 public class Foo {   &nbs……