Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

multiple threads and JNIEnv problem

843829Aug 9 2005 — edited Aug 11 2005
I am preparing a c++ dll that will be used by a peer group. This c++ dll is invoking a jvm inside via jni.

Now, I do not know how the peer group will use my c++ dll objects. i.e. they can be used in multiple threads. Currently, I am caching the jni implementation (jobject, jclass, jenv, jvm) within each c++ dll object.

Since the jenv needs to be different for each thread, I am thinking of preparing a map that has a threadID---jenv mapping. So, each object before invoking any of its methods can get the appropriate jenv based on the thread it is in.

I know that this is more of a design question, but this seems to be a common problem and l welcome all the "pearls of wisdom" from our jni gurus.

thanks in advance
Hitendra Gupta
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 8 2005
Added on Aug 9 2005
6 comments
1,073 views