I\'m trying to stop a thread but I can\'t do that :
public class Middleware {
public void read() {
try {
socket = new Socket(\"192.168.1.8\", 20
The usual way to stop a thread is to have a volatile flag and then check that in the run method. i.e.
class Scan extends Thread {
volatile stop = false;
public void run() {
while (!stop) {
try {
// my code goes here
} catch (IOException ex) {
thread.currentThread().interrupt();
}
}
}
public void stop(){
stop = true;
}
}
You can then call scan.stop().