On Mon, 10 Apr 2000, Craig R. McClanahan wrote:
> It's actually the other way around in at least some JVMs -- the garbage collector
> detects no other object references to an instance of your Singleton class (probably
> because there is no such instance, if you're using all static methods).
Hmm.. I'm coming around to your point of view. If a new classloader is
put in place, the singleton class will get reloaded anyway, and the
Singleton.getInstance() method will be invoked on a new Class object,
which will create a new instance object, and so on. The only way you
could avoid this would be to save the reference to the return value of
getInstance() somewhere in your application, and then you're likely to be
hit with ClassCastExceptions down the line due to the two different
ClassLoaders' versions of the Singleton class.
As always, paranoia leads to the most reliable code. Singletons should
only be used if you're in control of the entire VM, and with
servlets/JSPs, you most definitely are not..
Wes
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets