I would like to know how to pause my Thread efficiently and correctly with the Interrupt () method; I am with a part of my class that I started, but I would like to pause it.
My project consists of a websocket , which I would like to stop , but I did not succeed in my searches, so I decided to put it within a thread and pausing that way, I'd like some help.
Follow the code below:
public Runnable servidor = new Runnable() {
public void run() {
try {
new ServidorExt(8080).start();
} catch (UnknownHostException ex) {
Logger.getLogger(painelUsuarios.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
I am starting with the new thread (server) .start (); " and trying to stop it by " new Thread ) .interrupt (); " .