小编use*_*503的帖子

如何从jni端调用java方法?

我在jni方面做了一些c代码函数,所有工作都很好.

public native String getMessage() 
Run Code Online (Sandbox Code Playgroud)

函数返回从jni端到java端的字符串,它工作正常,所有其他jni代码也可以正常工作.但问题是如何在不使用return的情况下返回jni函数中的字符串,所以

public native void getMessagewithoutReturn()
Run Code Online (Sandbox Code Playgroud)

应该能够返回字符串.然后我,但getMessagewithoutReturn()函数永远不会使用pthread结束循环,如下所示,你可以看到:(它有效)

pthread_t native_thread;
pthread_create(&native_thread, NULL, native_thread_start_reading, env);
Run Code Online (Sandbox Code Playgroud)

并且每个循环迭代时间我都必须能够返回字符串,所以我不能使用return,因为它会停止函数运行.

pthread_t native_thread;
pthread_create(&native_thread, NULL, native_thread_start_reading, env);sted out that 
Run Code Online (Sandbox Code Playgroud)

我已经测试了那个posix线程,并且在android方面一切正常,因为它一直不是启动工作线程,但现在只是在每个迭代时间获取字符串的问题,而不使用函数返回.

java java-native-interface pthreads android-ndk

1
推荐指数
1
解决办法
9567
查看次数