thread problems with Java JNI