public synchronized void remove(int ID) { int pos = findClient(ID); if (pos >= 0) { ChatServerThread toTerminate = clients[pos]; System.out.println("Removing client thread " + ID + " at " + pos); if (pos < clientCount - 1) for (int i = pos + 1; i < clientCount; i++) clients[i - 1] = clients[i]; clientCount--; try { toTerminate.close(); } catch (IOException ioe) { System.out.println("Error closing thread: " + ioe); } toTerminate.stop(); } }