When you run a java program, a new JVM instance created, and its life ends togeter with the java program.
If you run three java programs, there are three JVM instances here.
JVM Achitecture
Runtime Data Area
Method Area, Heap, Java Stack, PC Register, Native Method Stack.
Method Area and Heap are shared by threads in the same JVM
Java Stack, PC Register and Native Method Stack are independend among threads.
Method Area
store meta data for class and static variables.
This is thread safe, cause it is shared among threads.
Its size is resizeable. Initial size, min size, max size...
Memory of it can be GC. Uninstall unreferrenced classes.
Heap
store instances of classes -- Objects
Jack Stack
Consist of Stack Frames. A stack frame contains all status about invoking for a java method. Everytime a thread calls a new method, JVM push a new stack frame into Jack Stack, and pop it out when the method returns.
PC Register
Always points to the next directive that going to be executed.
Here is the picture about how JVM allocate memory for runtime data area for threads: