Effective Java 71 Use lazy initialization judiciously

时间:2014-05-09 18:32:56   收藏:0   阅读:497

Lazy initialization - It decreases the cost of initializing a class or creating an instance, at the expense of increasing the cost of accessing the lazily initialized field. Depending on what fraction of lazily initialized fields eventually require initialization, how expensive it is to initialize them, and how often each field is accessed, lazy initialization can (like many "optimizations") actually harm performance.  

The only way to know for sure is to measure the performance of the class with and without lazy initialization.  

Principle

Effective Java 71 Use lazy initialization judiciously,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!