I have a JNI wrapper for Java functions that are called from C... I\'m trying to call some methods from different threads and I get an error when trying to get a new copy o
Please refer to the documentation to the chapter Attaching to the VM
.
You need to call AttachCurrentThread()
for each native thread at least once before you can use any of the JNI functions.
Thread created in Java are already attached.
So I your example whenever the GetEnv
call fails call AttachCurrentThread()
and you should be fine. Or make sure that whenver you create a sub thread you attach it to the VM.