1.
class Foo { private Helper helper = null; public synchronized Helper getHelper() { if (helper == null) helper = new Helper(); return helper; } // other functions and members... }
上面代码当helper实例化后仍然会加锁,效率低。
未完。。。。