public void stop() throws IOException {
   listenerServer.stop();
   messageReceiver.close(false);
   if (!executorService.isShutdown()) {
     executorService.shutdownNow();
   }
 }
 @Override
 public void run() {
   try {
     InputStream in = client.getInputStream();
     CharBuffer buffer = CharBuffer.allocate(5000);
     char ch;
     while (true) {
       ch = (char) in.read();
       if (((int) ch) == -1) {
         break;
       }
       while (ch != EOL) {
         buffer.put(ch);
         ch = (char) in.read();
       }
       buffer.flip();
       String s = new String(buffer.array(), 0, buffer.limit());
       messageReceiver.sendMessage(s + "\n");
       buffer.position(0);
       buffer.limit(5000);
     }
   } catch (Exception e) {
     e.printStackTrace();
     if (LOGGER.isLoggable(Level.WARNING)) {
       LOGGER.warning("Unable to process mesages from client" + client);
     }
   } finally {
     if (client != null) {
       try {
         client.close();
       } catch (Exception e) {
         e.printStackTrace();
       }
     }
   }
 }
 public void start() {
   messageReceiver.start();
   executorService.execute(listenerServer);
 }