1. 程式人生 > >獲取當前執行緒相關的JNIENV物件。不執行緒相關的JNIENV可能會掛掉。

獲取當前執行緒相關的JNIENV物件。不執行緒相關的JNIENV可能會掛掉。

A JNI interface pointer (JNIEnv*) is passed as an argument for each native function mapped to a Java method, allowing for interaction with the JNI environment within the native method. This JNI interface pointer can be stored, but remains valid only in the current thread. Other threads must first call AttachCurrentThread() to attach themselves to the VM and obtain a JNI interface pointer. Once attached, a native thread works like a regular Java thread running within a native method. The native thread remains attached to the VM until it calls DetachCurrentThread() to detach itself. [3]