Reputation: 280
This may be a trivial question and I just want to confirm my understanding on processes and multiple jvms.
I created a C++ dll program calling my java jar file via JNI. I then call this C++ dll in other C++ programs. As far as I know, in any particular program that I call the dll, only one jvm is allowed. In my project, a C++ program calls the dll once at the beginning and the end of the program, and the dll would create jvm when dll is called the first time and attach a thread to jvm when it called the second time.
My question is I will have many different C++ programs calling this dll, so it should create multiple jvms? This is one jvm creation per process, right? Or they are still considered as threads?
Thank you!
Upvotes: 1
Views: 809
Reputation: 74
A C/C++ program calling into Java APIs will create one JVM per process (when you call JNI_CreateJavaVM()
) and connect to it.
If you have several instances (processes) of this C/C++ program running, then in that case there is one JVM created for each of those instances.
Each JVM created is a process, not a thread.
Upvotes: 5