tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mikolaj Rydzewski <m...@ceti.pl>
Subject Re: Singleton in Tomcat 6.0 not working
Date Thu, 05 Jun 2008 15:06:00 GMT
ktou Ho wrote:
> 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? 
>   
Is anyone able to reproduce this?
>  
> public class RemoteDBConnections
> {
>     private static RemoteDBConnections sInstance = new RemoteDBConnections();
>     private static int counter=0;
>     
>     private RemoteDBConnections()
>     {
>         System.out.println("counter =" + (counter++));
>   
Add following line (assuming you do not override default toString method):

System.out.println(this.toString());

and compare results. 



-- 
Mikolaj Rydzewski <miki@ceti.pl>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message