'IODH'에 해당되는 글 1건

  1. 2012.11.23 [Java] Initialization on demand holder idiom (4)

http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom




When to use it

Use this pattern if the initialization of the class is expensive and it cannot be done safely at class-loading time and the initialization is highly concurrent. The crux of the pattern is the safe removal of the synchronization overhead associated with accessing a singleton instance.

[edit]When not to use it

Avoid this idiom if the construction of INSTANCE can fail. If construction of INSTANCE fails, an invocation of Something.getInstance() will result in a java.lang.NoClassDefFoundError error. Handling, or mishandling, of these types of construction initialization failures is a common criticism of this idiom and the singleton pattern in general.



Posted by 용식
TAG