I have seen the How to properly stop the Thread in Java?. But there is no try&catch in C.
I call a JNI function in a thread. I want to stop the thread when something goes wrong.
What should I do in error()
to prevent the code behind and stop the thread?
When I call error() in function 1, how to avoid subsequent function execution?
My code like this:
new Thread() (new Runnable() {
@Override
public void run() {
JNIfunction();
}
}).start();
JNIfunction():
while(flag) {
//Function1, call error() to stop thread when wrong.
//Function2, call error() to stop thread when wrong.
//Function3, call error() to stop thread when wrong.
...
}
error():
void error() {
flag= 0;
}