How to stop Interruptible Threads in Java
- by Dr.Lesh
I have a Java application that I CAN'T EDIT that starts a Thread wich has this run method:
public void run(){
while(true){
System.out.println("Something");
}
}
And at a certain moment I wanna stop it, but if I use thread.interrupt(); it won't work.
If I use thread.stop(); it works, but this method is deprecated and its use is discouraged because soon it will be removed from JVM.
Does anyone knows how to do it?
Thank you.