Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7150

Re: Singleton Pattern

Date 2011-08-16 18:10 -0700
From Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com>
Newsgroups comp.lang.java.programmer
Subject Re: Singleton Pattern
References (4 earlier) <4o6dnfZWI_mOZtTTnZ2dnUVZ_oqdnZ2d@earthlink.com> <l4udnXOiVIQ2itfTnZ2dnUVZ_uKdnZ2d@posted.palinacquisition> <mpqdnaDwH__n8NfTnZ2dnUVZ_q6dnZ2d@earthlink.com> <IbydnYJTAt_Y6tfTnZ2dnUVZ_vWdnZ2d@posted.palinacquisition> <d7ednWTTv8BvBNfTnZ2dnUVZ_sWdnZ2d@earthlink.com>
Message-ID <xaadnYJnh-ydiNbTnZ2dnUVZ_tCdnZ2d@posted.palinacquisition> (permalink)

Show all headers | View raw


On 8/16/11 9:25 AM, Patricia Shanahan wrote:
> On 8/16/2011 6:57 AM, Peter Duniho wrote:
> ....
>> Or looked at another way: if someone has messed up the class design such
>> that a singleton class is used even though the singleton instance is
>> never actually needed, I'm not sure I trust that person to correctly
>> implement even the basic explicit singleton initialization
>> synchronization code. Even in that case, better to suffer the potential
>> performance hit than to allow them to try to get the explicit
>> initialization right.
> ....
>
> I'm not convinced the method synchronization approach is bad from a
> performance point of view. I've never seen a getInstance method as a
> heavy hitter in a profile. I suspect that almost always the
> synchronization will be uncontended.  [...]

Nothing I wrote should be construed as suggesting a _performance_ 
problem with an explicitly synchronized initialization.  My point is 
simply that there's no reason to do it that way when the JVM will handle 
all the heavy lifting for you, with trivial syntax.

The only performance hit any of my posts mentioned would be the one that 
comes from initializing a singleton during a program's execution where 
it's never used.

Pete

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Singleton Pattern "vbhavsar@gmail.com" <vbhavsar@gmail.com> - 2011-08-13 13:56 -0700
  Re: Singleton Pattern markspace <-@.> - 2011-08-13 14:41 -0700
  Re: Singleton Pattern Patricia Shanahan <pats@acm.org> - 2011-08-13 14:48 -0700
  Re: Singleton Pattern Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-13 16:43 -0700
    Re: Singleton Pattern Ian <m4r35n357@gmail.com> - 2011-08-15 15:00 +0100
      Re: Singleton Pattern Lew <lewbloch@gmail.com> - 2011-08-15 07:56 -0700
        Re: Singleton Pattern Patricia Shanahan <pats@acm.org> - 2011-08-15 22:07 -0700
          Re: Singleton Pattern Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-16 00:09 -0700
            Re: Singleton Pattern Patricia Shanahan <pats@acm.org> - 2011-08-16 06:15 -0700
              Re: Singleton Pattern Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-16 06:57 -0700
                Re: Singleton Pattern Patricia Shanahan <pats@acm.org> - 2011-08-16 09:25 -0700
                Re: Singleton Pattern Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2011-08-16 18:10 -0700
  Re: Singleton Pattern Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-08-13 20:56 -0400
    Re: Singleton Pattern Lew <lewbloch@gmail.com> - 2011-08-13 21:12 -0700
  Re: Singleton Pattern Rajeev <rajeev.nospam@gmail.com> - 2011-08-14 06:37 -0700

csiph-web