java synchronized讨论

1.

class Foo { 
  private Helper helper = null;
  public synchronized Helper getHelper() {
    if (helper == null) 
        helper = new Helper();
    return helper;
    }
  // other functions and members...
  }

上面代码当helper实例化后仍然会加锁,效率低。 

未完。。。。

posted @ 2012-10-30 11:12  梅子毅  阅读(82)  评论(0编辑  收藏  举报