singleton is eval

把论坛关于singleton的帖子都看了一遍,越看越头晕
public class Singleton {
private static Singleton singleton = null;
public static Singleton getInstance() {
if(null == singleton) {
singleton = new Singleton;
}
return singleton;
}
}
除了这个可能会创建多个实例,其他的singleton应用是没有问题的
是不是这样啊 - -!

[该贴被gougou3250于2007年05月18日 18:08修改过]

自己顶.singleton没有问题,只要别滥用就行了,太多static引起性能问题
spring的bean默认就是singleton的,连static都不需要了,挺方便

Because static in normal compiler, it is initialized before all the other variables and classes.
so the problem is the life cycle of a singleton . in theory, it end up with the application termination.

or else it eats ur memory all the time but back to the real situation, you still need to see if this singlton has state or attributes or not. that is the root of the memory killer.

so do the calculation or benchmark your application then you will know if it is ok or not. dont forget the java is running on server-side.