I have one thread class which star in onCreate of an activity.
class MyThread extends Thread
{
void run()
{
//My code which takes time.
}
}
//-------------------------- To run the thread
MyThread mThread = new MyThread();
mThread.start();
On some external events i need to stop/destroy currently running thread.
And Then i create a new copy of MyThread and call start function on the new thread to run it.
But i am not able to destroy/stop the previous running thread.
Is there any API by which we can destroy running thread.
you cannot destroy…only the android will stop the thread when requires.. you cannot stop or destroy it.. instead try like this..
//————————– To run the thread
now when u want to stop the thread… change bool value to false
now your code doesnt run… and you can start new thread…