I have a thread implemented inside a class using runnable like this:
static Runnable myThread = new Runnable() {
public void run(){
try{
//do something forever
}catch(Exception e){
//something happened. Re-run this thread
}
}
}
I want to keep running this thread even when an exception is found. So, how can i do that inside the exception clause? Is there a more elegant solution to this?
Use a loop:
Whatever you do, I’d strongly encourage you to not silently ignore the exception. If there’s no better way to handle the exception, at the very least log it.