Suppose i have a file called A.java, when i compile it it makes a A.class now assume that i have opened two command prompts and at a time i'm hitting the command java A开发者_StackOverflow in both this commandprompt. will the jvm load the class twice?
There is no "the" JVM: you are starting two separate processes with their own heap, classloader, etc. The class will load twice, once in each JVM, separate from the other.
If you run the java command in two command prompts, two JVMs would be created and your class will be loaded into each JVM's classloader separately.
Yes, the class would be loaded twice.
Also, class may be loaded more then once into a single JVM, but with different classloader hierarchies.
精彩评论