Thread safety
Note these points about threading.
- Remember that Java adapters are multi-threaded by default. Your
adapter could be asked to handle multiple service calls on multiple threads
simultaneously. If the native code is not threadsafe, you may need to
single-thread the adapter by using the -t option in the start
script.
- Do not pass Java objects from one thread to another in C++ space, though
it's unlikely you'd need to do that in an adapter anyway.
- Normal rules for synchronization of globally accessible objects
apply.
- You must not pass JNIEnv* from one thread to another, or depend
on the pointer being the same in two different threads.
The JVM creates a distinct JNI environment for each thread, and the native
code must use only the pointer valid for the current thread.
