I have this problem in android. i have a main activity who calls a thread with this
Runnable work = new Runnable() {
public void run() {
while (kill) {
try {
Thread.sleep(5000);
connect();
} catch (InterruptedException ex) {
Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
};
kill its a public boolean in MainActivity. what can i do to save the thread so when i resume the activity i still can kill the thread?