In Java, are static class members shared among programs?

前端 未结 7 2029
独厮守ぢ
独厮守ぢ 2020-12-15 19:38

I imagine that no, they aren\'t, because every process has its own memory space, of course.

But how does the whole JVM thing actually work? Is there

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-15 20:27

    you should probably search more in the area of class loading if your main interest is about how static class members are instantiated.

    Different threads on the same VM may have their own static class nember instances if they used separate class loaders.

    The classic example here would be Apache Tomcat keeping different web applications separate, though lib jars might be common to all applications.

提交回复
热议问题