title: tcp multithreaded server java
body: <p>I trying to create multithreaded server, which will receive messages from different clients and then sends messages back.  I am using execute server to manage the creations of
  threads. But i am not sure if i'm doing it wright, i haven't used executor service before? And i have problem with this line
  <code>executor.execute(new Handler(client));</code> handler is abstract, cannot be initialized? How to fix it?   Will execute service solve problem with binding ports? will it make smth like queue of client's of requests?  thx in advance </p>
  
  <pre><code>package serverx;
  import java.io.IOException;
  import java.net.ServerSocket;
  import java.net.Socket;
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  import java.util.logging.Handler;
  
  
  public class ServerX {
  
    public static void main(String [] args){
  
      ExecutorService executor = Executors.newFixedThreadPool(30);
  
      ServerSocket server;
      try{
  
          server= new ServerSocket(5555);
          System.out.println ("Server started!");
  
          while(true) {
              try{
                  Socket client = server.accept();
  
                  //Thread t= new Thread (new Handler(client));
                  //t.start();
                  executor.execute(new Handler(client));    
              }
              catch (IOException e) {
                  e.printStackTrace();
              }
          }
  
      }catch (IOException el){
          el.printStackTrace();
      }
  
    }
  }
  </code></pre>
  
  <p>Handler:</p>
  
  <pre><code>public class Handler implements Runnable{
  
          private Socket client;
  
          public Handler(Socket client){
              this.client=client;}
          public void run(){
           //............   
  
      }
  
  }
  </code></pre>