Here I want to stop my thread or kill my thread which is created on Java layer, and this thread is calling JNI function. Sometimes as per my application requirement, I have to stop this JNI function execution on some conditions if its going on, otherwise not.
new Thread(new Runnable() {
@Override
public void run() {
// My jni function call, It calls my JNI layer C function.
}
}
Now when this thread execution is started and its doing work at JNI level I have no worries about that, but from other class or methods on some condition I want to stop this JNI work so how can I stop this thread.
Note: Here my thread also has no while-loop so I cant check with some global flag variable also.
So does anyone have an idea on how to kill a thread while its call any JNI function without while loop.