Interrupt will not stop the thread. it just sets the flag to true to signal the thread to stop the execution soon.
to stop the execution add global variable as
private volatile boolean exit = false;
and you add one method in your 2nd class
public void requestExit(){
exit = true;
}
inside run ()
of your thread do something like this
if (exit == true){
return;
}
whenever you want to call just call this method requestExit() from your main() or wherever you want to stop
this is the best way to stop the thread.. using stop() on thread is dangerous as it does not clear any resources and its not advisable to use even by oracle hence deprecated.
let me know for any issues