You
cannot syncronize a static variable. It is always better if you modify your
variables using set/get methods. Once you syncronize your set method your
variable would be thread safe.
I saw
people using synchonize blocks for servlet instance variables instead
of maintaining local variables. Since servlet is a singleton this is
necessary. Apart from this case(Singleton) I did not see
people trying to synchronize static
variables.
Regards,
Suresh
Koya
-----Original Message-----
From: An
interest list for Sun Java Center J2EE Pattern Catalog
[mailto:J2EEPATTERNS-INTEREST@JAVA.SUN.COM]On Behalf Of Julia
Liu
Sent: Friday, April 01, 2005 9:47 PM
To:
J2EEPATTERNS-INTEREST@JAVA.SUN.COM
Subject: Re: Is Singleton thread
safe?
Thanks for reply. Could I Synchronized static
varible?
Sureshbabu Koya
<Sureshbabu.Koya@SYMPHONYSV.COM> wrote:
Making a singleton thread safe is up to you. You should also think
about how the performance get a hit if you want to make a singleton
threadsafe.
regards,
Suresh
Hi,
Is Singleton thread safe? Why?
Thanks
Julia
Liu 
Yahoo! Messenger
Show us what our next emoticon should look like. Join
the fun.
====================================================================
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@java.sun.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@java.sun.com
Julia Liu

Yahoo! Messenger
Show us what our next emoticon should look like. Join
the fun.
==================================================================== 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@java.sun.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@java.sun.com