> When implementing a Singleton pattern, I sometimes consider whether to
> use the classic "getInstance()" concept, or simply implement a "static
[quoted text clipped - 7 lines]
>
> Is there any truth to this?
It was true with the JDK 1.0. The JDK 1.1 java command had a -noclassgc
option that prevented classes from being gargage collected. Starting
with JDK 1.2 a class may not be garbage collected until after the
ClassLoader that loaded the class may be. Starting with JDK 1.2
the java command has a -Xnoclassgc option that disables class garbage
collection.
No matter what JVM you use, you can prevent a class from being garbage
collected by keeping a reference to the class in another class or object
that will not be garbage collected.
Stephen Kellett - 23 Aug 2003 00:37 GMT
>> When implementing a Singleton pattern, I sometimes consider whether to
>> use the classic "getInstance()" concept, or simply implement a "static
[quoted text clipped - 7 lines]
>>
>> Is there any truth to this?
Even if the class is unloaded, at the point at which a call is made to a
static method, the class will be loaded. If you want to avoid any such
problems, always ensure that you have one reference in use.

Signature
Stephen Kellett
Object Media Limited http://www.objmedia.demon.co.uk
RSI Information: http://www.objmedia.demon.co.uk/rsi.html