The Thread
ends when the method run
ends. Since you have while
loop you have to force explicitly the exit condition
Android does thread end itself after executing code
-
08-10-2022 - |
Question
So, I'm searching on net for a while and now I'm confused... do I need to explicitly end thread after code is executed or thread does it automatically?
Code:
Runnable waitForInput = new Runnable() {
public void run() {
while (!inputOK) {
try {
Thread.sleep(100);
} catch (Exception e) {}
}
if (!ret_val.equals("")) {
port = ret_val;
}
inputOK = false;
ret_val = "";
}
};
Thread inputW = new Thread(waitForInput);
inputW.start();
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow