Make Java JNI able to run on another thread.