Will Jvm load the class file twice?

Suppose I have a file called A.java, when I compile it, it now does A.class, suppose I open two command lines, and at the same time I press java A command in this command message. will jvm load the class twice?

+4
source share
4 answers

No JVM: you start two separate processes with your heap, class loader, etc. The class will be loaded twice, once in each JVM, separately from the other.

+9
source

If you run the java command at two command prompts, two JVMs will be created, and your class will be loaded into each JVM classloader separately.

+2
source

Yes, the class will be loaded twice.

+2
source

In addition, a class can be loaded more than once in a single JVM, but with different class hierarchies.

+1
source

Source: https://habr.com/ru/post/1341932/


All Articles