Hmm... nice links!
  The first one said about a proposal of solving this problem through
the use of "volatile" keyword... this was implemented in jdk 1.4? It
seems that site is older than this release...
  I'm not sure yet of how I will do it... I would not like to
synchronize the entire method because it'll probably be called million
of times in my app

On Wed, 2003-02-05 at 09:42, Daniel Brown wrote:
> The simple answer is 'no'.
> 
> For the more complex answer, read the 'Double-Checked Locking is Broken'
> declaration at:
> 
> http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html
> 
> To complicate matters even further, check out the JavaDoc to the Fast*
> utilities in the Jakarta commons. For example:
> 
> http://jakarta.apache.org/commons/collections/api/org/apache/commons/collect
> ions/FastTreeMap.html
> 
> (apologies for the wrap).
> 
> Dan.
> 
> > -----Original Message-----
> > From: Felipe Schnack [mailto:[EMAIL PROTECTED]]
> > Sent: 05 February 2003 11:21
> > To: Tomcat Users List
> > Subject: singleton creation (ot)
> >
> >
> >   I was wondering... this code is valid to avoid excessive use of
> > synchronized code? I think so, but we never know :-)
> >   This is the default getInstance() method of a singleton (simplified):
> >
> > public Object getInstance()
> > {
> >   if (INSTANCE == null)
> >   {
> >     synchronized (this)
> >     {
> >       if (INSTANCE == null)
> >       {
> >         INSTANCE = this.getClass().newInstance();
> >       }
> >     }
> >   }
> >   return INSTANCE;
> > }
> >
> > --
> >
> > Felipe Schnack
> > Analista de Sistemas
> > [EMAIL PROTECTED]
> > Cel.: (51)91287530
> > Linux Counter #281893
> >
> > Centro Universit�rio Ritter dos Reis
> > http://www.ritterdosreis.br
> > [EMAIL PROTECTED]
> > Fone/Fax.: (51)32303341
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
-- 

Felipe Schnack
Analista de Sistemas
[EMAIL PROTECTED]
Cel.: (51)91287530
Linux Counter #281893

Centro Universit�rio Ritter dos Reis
http://www.ritterdosreis.br
[EMAIL PROTECTED]
Fone/Fax.: (51)32303341


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to