Undo android thread programmatically
I have this thread:
t = new Thread() {
@Override
public void run() {
try {
while (!isInterrupted()) {
Thread.sleep(1);
runOnUiThread(new Runnable() {
@Override
public void run() {
TimeCounter++;
textview.setText("Your reaction time:"
+ TimeCounter + "MS");
}
});
}
} catch (InterruptedException e) {
}
}
};
t.start();
I want to undo it, I tried t.interrupt();
it but it didn't work, is there any other way?
+3
source to share
3 answers
I had a problem related to this before. You may find this link helpful as I solved this problem. Also, as mentioned, it is rather strange that you set the thread within 1 millisecond. The topic was not deleted properly
0
source to share