I need a solution to properly stop the thread in Java.
I have IndexProcessor
class which implements the Runnable interface:
public class
Sometime I will try 1000 times in my onDestroy()/contextDestroyed()
@Override
protected void onDestroy() {
boolean retry = true;
int counter = 0;
while(retry && counter<1000)
{
counter++;
try{thread.setRunnung(false);
thread.join();
retry = false;
thread = null; //garbage can coll
}catch(InterruptedException e){e.printStackTrace();}
}
}