开发者

How to identify the singleton object in JVM?

Does JVM manage any special attribute for singleton object? How can I identify that in 开发者_Go百科my program?


No. There would be just a single instance of that particular class in the heap. But again, it doesn't necessarily means that that class is a singleton. It can be a normal class just instantiated once.


I hope you meant singleton class's object.. I know there is singleton class which will make sure there is only one instance of that class ever created..(even after taking reflection, serialization-deserialization into consideration) I think you cannot consider an object as a singleton object just because you did not find any other object of the same class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜