Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Pattern »

Re: Is Singleton thread safe?

Dan Marchant

2005-04-05

Replies:

This also depends if you mean final in the sense of an instance
variable or the class name.

public final static Singleton singleton = new Singleton();

or if you mean

public final class Singleton {

 // etc...
}


Two different JVM behaviors, what George is referring to is the second.
Hope this helps.

- Dan

On Apr 5, 2005 7:10 AM, George Maggessy <george.maggessy@(protected):
> As far as I know, declaring a class as a final one helps the jvm in the
> task of searching the hierarchy class tree, that is, it improves the
> application performance.
>
> Atte.,
> George Maggessy
>
> --- Original Message ---
>
>
> As far as I understand -
>
> Declaring a class FINAL means that class designer does not wants this class
> to be extendible, so this class cannot provide any additional functionality.
>
> Desiging a class Singleton indicates that at any instant of time there will
> be only one instance (one object) of this class.
>
> So by making a Singleton class Final -> means that there will be only one
> instance of this class which cannot be extended for adding new
> functionality.
>
> I wonder why will be a class declared FINAL if it has to be extended in
> functionality by other classes?
>
> Singleton and FINAL ar 2 different concept all together.
>
>
> Regards,
> Garima.
>
>
>
> On Apr 5, 2005 5:23 AM, Julia Liu <julialiu@(protected):
> >
> > If I declare Singleton class as final, How could I add new functioality
> > to the class? Thanks.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Julia Liu
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam? Yahoo! Mail has the best spam protection around
> > http://mail.yahoo.com
> ====================================================================
> Companion Site: http://www.corej2eepatterns.com J2EE BluePrints:
> http://java.sun.com/blueprints/corej2eepatterns List
> Archive:
> http://archives.java.sun.com/archives/j2eepatterns-interest.html
> Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
> listserv@(protected)
>
> ====================================================================
> Companion Site: http://www.corej2eepatterns.com J2EE BluePrints:
> http://java.sun.com/blueprints/corej2eepatterns List
> Archive:
> http://archives.java.sun.com/archives/j2eepatterns-interest.html
> Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
> listserv@(protected) >
> ====================================================================
> Companion Site: http://www.corej2eepatterns.com J2EE BluePrints:
> http://java.sun.com/blueprints/corej2eepatterns List
> Archive:
> http://archives.java.sun.com/archives/j2eepatterns-interest.html
> Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to
> listserv@(protected)

====================================================================
Companion Site: http://www.corej2eepatterns.com
J2EE BluePrints: http://java.sun.com/blueprints/corej2eepatterns
List Archive: http://archives.java.sun.com/archives/j2eepatterns-interest.html
Unsubscribing: email "signoff J2EEPATTERNS-INTEREST" to listserv@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.