<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>ronin: Lazy Loading Singletons</title>
    <link>http://blogs.divisibleprime.com/ronin/articles/2007/01/28/lazy-loading-singletons</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Stuff</description>
    <item>
      <title>Lazy Loading Singletons</title>
      <description>&lt;p&gt;&lt;a href="http://www.oreillynet.com/onjava/blog/2007/01/singletons_and_lazy_loading.html"&gt;Dejan Bosanac&lt;/a&gt; over at O&amp;#8217;Reilly points out a &lt;a href="http://en.wikipedia.org/wiki/Initialization_on_demand_holder_idiom"&gt;style&lt;/a&gt; of initializing singletons which I hadn&amp;#8217;t seen before.&lt;/p&gt;

&lt;p&gt;I think there&amp;#8217;s 3 things worth saying about this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Don&amp;#8217;t use the Singleton pattern if you can avoid it.  I should really dig up some references for this comment but I can&amp;#8217;t be arsed.&lt;/li&gt;
&lt;li&gt;Use a static initializer if you can.  It avoids having another class involved and I think it reads a bit easier.&lt;/li&gt;
&lt;li&gt;If you really need to have the Singleton inited on the getInstance call, then go ahead and use the on demand holder.  In my experience the first call to a Singleton is the getInstance method so the static initialiser will be called at that stage anyway.&lt;/li&gt;
&lt;/ol&gt;</description>
      <pubDate>Sun, 28 Jan 2007 11:40:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:fa9c4aba-d872-4541-8f3e-e5a16f183ac6</guid>
      <author>Kerry</author>
      <link>http://blogs.divisibleprime.com/ronin/articles/2007/01/28/lazy-loading-singletons</link>
      <category>Tech</category>
      <category>Java</category>
      <category>java</category>
      <category>singleton</category>
      <category>pattern</category>
      <trackback:ping>http://blogs.divisibleprime.com/ronin/articles/trackback/796</trackback:ping>
    </item>
  </channel>
</rss>
