Hi, I'm from Italy so I apologize for my English.
The problem is this, I created a separated Thread to listen the connections that come from the various clients, when it receive a connection it creates a new Thread to manage the connection.
The problem is that I need to stop the Thread (the one that look for new connetions), whenever I need it, but how can i do it if the method ServerSocket.accept(); stop the execution of the thread.
The listener of new connections extends Thread and this is the run method overridden.
public void run() {
ServerSocket ss;
Server myServer; /* Another class that extends Thread to manage the connection */
while (true) {
try {
ss = new ServerSocket(port, queueLength);
Socket sd = ss.accept();
myServer = new Server(sd);
myServer.start();
}
catch (IOException e) {
}
}
}