How are singletons handled in a web application?

前端 未结 4 1035
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 10:35

From what I understand, a singleton is basically when you have a private member that represents the object you want to have a single instance for. Then in the constructor y

4条回答
  •  忘掉有多难
    2020-12-14 11:00

    If your execution environment uses multiple class loaders, then you get one singleton per instance of your class. If your singleton class is loaded into different class loaders, then it's actually two distinct classes and then there will be two "singleton" instances.

    You can find some info on the Tomcat class loaders in the documentation.

提交回复
热议问题