In my Android NDK app, the C++ library runs in a different thread than the ui thread. A JNI call from C++ creates an instance of Java class Foo. I'd like to have another Java object Bar, created on the UI thread, to call methods on Foo. How do I do that?
Difficulty bonus: Foo has several native methods that call corresponding JNI functions from the C++ library. How to I ensure that those calls are thread safe?
Difficulty bonus 2: Some of Bar's methods are actually overrides of callback methods, specifically of WebViewClient. The return code of some of the methods depend on the result of the call to Foo's method. So the call to Foo would need to happen immediately.