Keeping a global reference to the JNIEnv environment
You cannot cache the JNIEnv pointer. Read about it here: The JNI interface pointer (JNIEnv) is valid only in the current thread. Should another thread need to access the Java VM, it must first call AttachCurrentThread() to attach itself to the VM and obtain a JNI interface pointer. Once attached to the VM, a native … Read more