0

I am using simple java class extended to Thread for doing background network or other data operations. I want to quit the code in case exception occurs. Presently the code do not stop whether exception occurs or not. I tired using return; and .interrupt(); by making object of class but none of them helped me in stopping the code.

My class structure as below:

public class sample extends Thread{
Context mcontext;
public sample(Context context){
this.mcontext = context;
}
@override
public void run(){
scan(mcontext);
}

public void scan(){

try{
//Code to execute
}catch(Exception e){e.printStackTrace}
//What to do to exit code here reaching first time
}
}
Panache
  • 1,701
  • 3
  • 19
  • 33

0 Answers0