0

我正在使用 JNI 实现一个 android 应用程序,

我有一些 JNI 函数,

#include <stdio.h>
#include <jni.h>
// other header files

JNIEXPORT jint JNICALL Java_com_example_projectpmic_NativeLib_get_1clock_1status
  (JNIEnv *env, jobject obj, jint v)

{ / will do something
 pthread_t native_thread ;  
 pthread_create(&native_thread,NULL,native_thread_funtion,NULL) ;
}
 JNIEXPORT jint JNICALL Java_com_example_projectpmic_NativeLib_get_name
  (JNIEnv *env, jobject obj, jint v)

{ / will do something


}

void *native_thread_function(void* args)
{
    /*I want to call the above get_name()  function in this thread function ,       
  // How to do that ? */

}

注意:这两个函数在同一个 .c 文件中

4

1 回答 1

0

要从任意本机方法调用 JNI 方法,您需要一个 JNIEnv 指针,而获得该指针的唯一地方是 AttachCurrentThread()。

于 2013-06-19T09:11:22.837 回答