I have thread in my android app which finish its task but still it is not exit , when I run it again I got error that thread is already alive
my thread
Thread mythreads = new Thread()
{
@Override
public void run() {
// do some work
// exit point
}
};
so please how can I stop this even thread finish it code execution , but when I try to run it again it give me error
java.lang.IllegalThreadStateException: Thread already started
I try to stop with it with my threadkill function code but no success
public void killthread(Thread tname){
try {
if (tname.isAlive()) {
Log.d("tag1","Thread is Alive");
tname.interrupt();
tname = null;
}
}catch (Exception e){
e.printStackTrace();
}
}