Detaching current thread in Jni

It is very important because after a while JNI just stop working. It
happens all the time on Nexus 4 on Android 4.4. Please look and give
some feedback.