<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How to write a Singleton (3/5)</title>
	<atom:link href="http://www.javablogging.com/how-to-write-a-singleton-35/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javablogging.com/how-to-write-a-singleton-35/</link>
	<description>Tracking surprises, features and bugs</description>
	<lastBuildDate>Wed, 25 Aug 2010 14:00:30 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: vibram five fingers kso shoes</title>
		<link>http://www.javablogging.com/how-to-write-a-singleton-35/comment-page-1/#comment-3186</link>
		<dc:creator>vibram five fingers kso shoes</dc:creator>
		<pubDate>Sat, 03 Jul 2010 04:00:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=158#comment-3186</guid>
		<description>Women&#039;s  &lt;a href=&quot;http://www.vibramfivefingers.name&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt;vibram five fingers kso shoes&lt;/strong&gt;&lt;/a&gt; Gray Pink Shoes can keep your feet in the freest condition,just as if your were barefooted. &lt;strong&gt;vibram five fingers kso shoes &lt;/strong&gt;is made of the best and proper materials,so you don&#039;t need to doubt of its comfort with so thin sole and upper.
Gray match with a dreamlike and romantic color,pink&lt;a href=&quot;http://www.vibramfivefingers.name&quot; rel=&quot;nofollow&quot;&gt;&lt;strong&gt; vibram five fingers kso shoes&lt;/strong&gt;&lt;/a&gt; is very consistent with the style of young girls.In this busy and tense times,people need relax without any fetter.</description>
		<content:encoded><![CDATA[<p>Women&#8217;s  <a href="http://www.vibramfivefingers.name" rel="nofollow"><strong>vibram five fingers kso shoes</strong></a> Gray Pink Shoes can keep your feet in the freest condition,just as if your were barefooted. <strong>vibram five fingers kso shoes </strong>is made of the best and proper materials,so you don&#8217;t need to doubt of its comfort with so thin sole and upper.<br />
Gray match with a dreamlike and romantic color,pink<a href="http://www.vibramfivefingers.name" rel="nofollow"><strong> vibram five fingers kso shoes</strong></a> is very consistent with the style of young girls.In this busy and tense times,people need relax without any fetter.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Manes</title>
		<link>http://www.javablogging.com/how-to-write-a-singleton-35/comment-page-1/#comment-86</link>
		<dc:creator>Ben Manes</dc:creator>
		<pubDate>Wed, 05 Aug 2009 17:06:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=158#comment-86</guid>
		<description>@Mohamed
Sure, the following relies on the inner class being loaded separately. On load it creates the parent&#039;s instance. This relies on classloading being a serial process, so synchronization is not needed. (Forgive formatting if it shows up poorly!)

public class Singleton {
  private Singleton() {}

  public Singleton getInstance() {
    return Holder.INSTANCE;
  }

  private static final class Holder {
    static final Singleton INSTANCE = new Singleton();
  }
}</description>
		<content:encoded><![CDATA[<p>@Mohamed<br />
Sure, the following relies on the inner class being loaded separately. On load it creates the parent&#8217;s instance. This relies on classloading being a serial process, so synchronization is not needed. (Forgive formatting if it shows up poorly!)</p>
<p>public class Singleton {<br />
  private Singleton() {}</p>
<p>  public Singleton getInstance() {<br />
    return Holder.INSTANCE;<br />
  }</p>
<p>  private static final class Holder {<br />
    static final Singleton INSTANCE = new Singleton();<br />
  }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mohamed El-Beltagy</title>
		<link>http://www.javablogging.com/how-to-write-a-singleton-35/comment-page-1/#comment-84</link>
		<dc:creator>Mohamed El-Beltagy</dc:creator>
		<pubDate>Wed, 05 Aug 2009 10:14:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=158#comment-84</guid>
		<description>The synchronization part is a popular trick that many developers, as I&#039;ve seen, fall into.
But I do agree with Ran as well: &quot;if the singleton object can be instantiated multiple times without penalty, you could drop the synchronize altogether&quot;

@Ben: it&#039;s very sad that you did not mention what you mean by using a static inner class as the instance holder. I&#039;m one of the people who would like to know it.</description>
		<content:encoded><![CDATA[<p>The synchronization part is a popular trick that many developers, as I&#8217;ve seen, fall into.<br />
But I do agree with Ran as well: &#8220;if the singleton object can be instantiated multiple times without penalty, you could drop the synchronize altogether&#8221;</p>
<p>@Ben: it&#8217;s very sad that you did not mention what you mean by using a static inner class as the instance holder. I&#8217;m one of the people who would like to know it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ignacio Coloma</title>
		<link>http://www.javablogging.com/how-to-write-a-singleton-35/comment-page-1/#comment-83</link>
		<dc:creator>Ignacio Coloma</dc:creator>
		<pubDate>Wed, 05 Aug 2009 09:32:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=158#comment-83</guid>
		<description>There are already a zillion articles dealing with singletons and lazy initialization. For the sake of S/N ratio on the Internet, please add something that is not already there: 

http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html

Five articles talking about singleton initialization seems like a bit too much.</description>
		<content:encoded><![CDATA[<p>There are already a zillion articles dealing with singletons and lazy initialization. For the sake of S/N ratio on the Internet, please add something that is not already there: </p>
<p><a href="http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html" rel="nofollow">http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html</a></p>
<p>Five articles talking about singleton initialization seems like a bit too much.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Manes</title>
		<link>http://www.javablogging.com/how-to-write-a-singleton-35/comment-page-1/#comment-82</link>
		<dc:creator>Ben Manes</dc:creator>
		<pubDate>Wed, 05 Aug 2009 07:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=158#comment-82</guid>
		<description>Ran&#039;s optimizations aren&#039;t available on older JVMs, like the Sun JDK5. I&#039;ve seen noticible performance problems due to lazy singleton initialization. The locking can be avoided by using a static inner class as the instance holder, which relies on class-loading. Its fast, simple, and sadly not well known.</description>
		<content:encoded><![CDATA[<p>Ran&#8217;s optimizations aren&#8217;t available on older JVMs, like the Sun JDK5. I&#8217;ve seen noticible performance problems due to lazy singleton initialization. The locking can be avoided by using a static inner class as the instance holder, which relies on class-loading. Its fast, simple, and sadly not well known.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ran Biron</title>
		<link>http://www.javablogging.com/how-to-write-a-singleton-35/comment-page-1/#comment-77</link>
		<dc:creator>Ran Biron</dc:creator>
		<pubDate>Tue, 04 Aug 2009 17:55:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.javablogging.com/?p=158#comment-77</guid>
		<description>You forgot to mention that even if instantiation is slow, after instantiation the monitor would almost always be locked on the &quot;fast track&quot; (optimistic no-locking with fallback) instead of the &quot;slow track&quot; (preemptive locking).

Also, if the singleton object can be instantiated multiple times without penalty, you could drop the synchronize altogether.</description>
		<content:encoded><![CDATA[<p>You forgot to mention that even if instantiation is slow, after instantiation the monitor would almost always be locked on the &#8220;fast track&#8221; (optimistic no-locking with fallback) instead of the &#8220;slow track&#8221; (preemptive locking).</p>
<p>Also, if the singleton object can be instantiated multiple times without penalty, you could drop the synchronize altogether.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
