tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktou Ho <hk...@hotmail.com>
Subject Singleton in Tomcat 6.0 not working
Date Wed, 04 Jun 2008 22:14:53 GMT

Hi,
I am using Tomcat 6.0.16 with JDK 1.6. I created a web application and deployed it as ROOT.
(I removed the default ROOT which comes with tomcat). 
The problem I am facing is the Singleton is not working at all in the servlet.  I tried to
synchnozed the constructor or make it static. I still get two instances of the objects.  How
can I solve the problem? 
 
e.g.
=======
public class RemoteDBConnections
{
    private static RemoteDBConnections sInstance = new RemoteDBConnections();
    private static int counter=0;
    
    private RemoteDBConnections()
    {
        System.out.println("counter =" + (counter++));
 
    };
 
    public  static synchronized RemoteDBConnections getInstance()
    {
        return sInstance;
    }
}
======
Thanks in advance
Elwin
_________________________________________________________________
Search that pays you back! Introducing Live Search cashback.
http://search.live.com/cashback/?&pkw=form=MIJAAF/publ=HMTGL/crea=srchpaysyouback
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message