multithreading - Getting error "attempting to detach while still running code" when calling JavaVm->DetachCurrentThread -


getting error while calling (*javavm)->detachcurrentthread(*javavm). tried copy paste google jni example still unable figure out how solve problem.

jint jni_onload(javavm *vm, void *reserved) {         javavm = vm;         jnienv *env;         if ((*vm)->getenv(vm, (void **) &env, jni_version_1_6) != jni_ok) {             return jni_err;         }         return jni_version_1_6;     }      void *start_download( ) {         javavm *jvm = javavm;         jnienv *env;         jint res = (*jvm)->getenv(jvm, (void**)&env, jni_version_1_6);         if (res != jni_ok) {             res = (*jvm)->attachcurrentthread(jvm, &env, null);             if (jni_ok != res) {                 logd("failed attachcurrentthread, errorcode = %d", res);                 return null;             }         }         (*jvm)->detachcurrentthread(jvm);         return null;     }       void download_in_thread(const char *url, const char *path) {         int thread_id;         int = 1;         pthread_t p_thread;         pthread_attr_t threadattr_;          pthread_attr_init(&threadattr_);         pthread_attr_setdetachstate(&threadattr_, pthread_create_detached);          thread_id = pthread_create(&p_thread, &threadattr_, start_download(url, path), (void *) &a);     } 


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -