PrintWriter out; public void run() { while (connected) { // Check to see if there is something to send while (sendBuffer.size() > 0) { for (int i = 0; i < sendBuffer.size(); i++) { out.println(sendBuffer.get(i)); } out.flush(); sendBuffer.clear(); } // Wait for input try { parseInput(in.nextLine()); } catch (NoSuchElementException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }