Basically I have a ServerSocket listener , on new incoming connection the program executes a thread to serve it , after the thread finishes , the program doesn't continue this is the listener
client = listenSocket.accept();
new HandleConnection(client);//HandleConnections extends thread and start
//method is called in the constructor
counter++;
System.out.println("Number of clients served : " + counter);
this is the thread
public HandleConnection(Socket client) {
this.client = client;
this.start();
}
public void run() {
try {
in = new BufferedReader(new InputStreamReader(
client.getInputStream()));
out = new PrintWriter(client.getOutputStream(), true);
handler();
System.out.println("Ending Thread !");
} catch (IOException e) {
//System.out.println("socket closed");
e.printStackTrace();
}
}
the message "Ending Thread !" is executed normally , but the counter++ and the following println statement are never executed