private static ${enclosing_type} instance; private ${enclosing_type}(){} public static ${enclosing_type} getInstance(){ if(null == instance){ instance = new ${enclosing_type}(); } return instance; }
http://java.sun.com/developer/Books/performance2/chap3.pdf
http://jroller.com/trackback/need2know/Weblog/race_condition_and_singleton_pattern
http://jroller.com/trackback/need2know/Weblog/race_condition_and_singleton_pattern
although, be careful of using singletons in clustered environments. try something cluster-aware caching mechanisms, like OSCache, instead.
You need to create an account or log in to post comments to this site.