public class MultiClient implements Runnable { static long[] times = new long[25]; String hostname = null; int port = -1; private int menuCommand = -1; private int id = -1; private long startTime = -1; private long stopTime = -1; private long runTime = -1; Socket clientSocket = null; DataOutputStream os = null; BufferedReader is = null; public MultiClient(String hostname, int port, int menuCommand, int id) { this.hostname = hostname; this.port = port; this.menuCommand = menuCommand; this.id = id; try { clientSocket = new Socket(hostname, port); Date mydate = new Date(); startTime = mydate.getTime(); os = new DataOutputStream(clientSocket.getOutputStream()); is = new BufferedReader(new InputStreamReader(clientSocket .getInputStream())); } catch (UnknownHostException e) { System.err.println("Don't know about host: " + hostname); } catch (IOException e) { System.err.println("Couldn't get I/O for the connection to: " + hostname); } } public void run() { try { os.writeBytes("4" + "\n"); String responseLine; while (!(responseLine = is.readLine()).equals("endprocess")) { } Date mydate = new Date(); stopTime = (mydate.getTime()); os.writeBytes("7"); runTime = stopTime - startTime; times[id] = runTime; Client2.times[id] = times[id]; Client2.numClients--; os.close(); is.close(); clientSocket.close(); } catch (UnknownHostException e) { System.err.println("Trying to connect to unknown host: " + e); } catch (IOException e) { System.err.println("IOException: " + e); } catch (NullPointerException e) { System.err.println("NPE: " + e + " \n"); e.printStackTrace(); } } }