Can I create an object only used by each Thread in JNI?
In Java I create some Threads, and they call the same native method like:
public native String go(String str);
In C Language, I have to make an object for each Thread, and the object is only used开发者_如何学Go by each Thread.
Global reference cannot be used because it's shared by all Threads.
I don't want to create the object each time I invoke the JNI method.
How can I implement this?
So you want thread-local Java objects at the JNI side? Just create a ThreadLocal and store it in a global reference.
精彩评论