wolf97084
wolf97084

Reputation: 280

processes and multiple jvm

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

Answers (1)

Kalyan
Kalyan

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

Related Questions