Jini and global reference

E

Elpitzote

I tried to use a Jni global reference in C code but it works well on
the same Thread with multiple calls of the native function, but it
doesn't works across different Threads.
How can i share a global variable between Threads?
Any suggestion is appreciated.
Thanks.

Lorenzo Viti
 
C

Chris Uppal

Elpitzote said:
I tried to use a Jni global reference in C code but it works well on
the same Thread with multiple calls of the native function, but it
doesn't works across different Threads.

That /should/ work -- it's one of the things that global refs are /for/. I
suspect that you may be attempting to use the wrong JNIEnv. Each thread that
is allowed to use JNI at all has at least one JNIEnv (depending on how deeply
nested callbacks between Java and JNI are), and you always have to use the
correct one. If that guess isn't correct, then you'll have to say more about
how/what you are doing with your threads and references.

-- chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top