package com.tcp.server;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Date;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MultiThreadedTCPServer {

    private static class TCPWorker implements Runnable {

        private Socket client;
        private String clientbuffer;

        public TCPWorker(Socket client) {
            this.client = client;
            this.clientbuffer = "";
        }

        @Override
        public void run() {

            try {
                System.out.println("Client connected with: " + this.client.getInetAddress());

                DataOutputStream output = new DataOutputStream(client.getOutputStream());
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(this.client.getInputStream())
                );

                this.clientbuffer = reader.readLine();
                System.out.println("[" + new Date() + "] Received: " + this.clientbuffer);

                output.writeBytes(this.clientbuffer.toUpperCase() + System.lineSeparator());
            } catch (IOException e) {
                e.printStackTrace();
            }

        }

    }

    public static ExecutorService TCP_WORKER_SERVICE = Executors.newFixedThreadPool(10);

    public static void main(String args[]) {
        try {
            ServerSocket socket = new ServerSocket(5678);

            System.out.println("Server listening to: " + socket.getInetAddress() + ":" + socket.getLocalPort());

            while (true) {
                Socket client = socket.accept();

                TCP_WORKER_SERVICE.submit(
                        new TCPWorker(client)
                );

            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

@@ -345,20 +345,17 @@
 rver %7B%0A%0A
-    
+%09
 private 
@@ -400,24 +400,18 @@
 able %7B%0A%0A
-        
+%09%09
 private 
@@ -425,24 +425,18 @@
 client;%0A
-        
+%09%09
 private 
@@ -457,24 +457,18 @@
 uffer;%0A%0A
-        
+%09%09
 public T
@@ -493,28 +493,19 @@
 ient) %7B%0A
-            
+%09%09%09
 this.cli
@@ -518,28 +518,19 @@
 client;%0A
-            
+%09%09%09
 this.cli
@@ -545,35 +545,23 @@
 r = %22%22;%0A
-        %7D%0A%0A        
+%09%09%7D%0A%0A%09%09
 @Overrid
@@ -562,24 +562,18 @@
 verride%0A
-        
+%09%09
 public v
@@ -589,42 +589,21 @@
  %7B%0A%0A
-            try %7B%0A                
+%09%09%09try %7B%0A%09%09%09%09
 Syst
@@ -677,32 +677,20 @@
 ss());%0A%0A
-                
+%09%09%09%09
 DataOutp
@@ -755,32 +755,20 @@
 eam());%0A
-                
+%09%09%09%09
 Buffered
@@ -806,33 +806,8 @@
 der(
-%0A                        
 new 
@@ -857,45 +857,16 @@
 m())
-%0A                );%0A%0A                
+);%0A%0A%09%09%09%09
 this
@@ -900,32 +900,20 @@
 Line();%0A
-                
+%09%09%09%09
 System.o
@@ -980,32 +980,20 @@
 ffer);%0A%0A
-                
+%09%09%09%09
 output.w
@@ -1006,39 +1006,32 @@
 tes(
-this.clientbuffer.toUpperCase()
+%22WELCOME%22 + clientbuffer
  + S
@@ -1054,28 +1054,19 @@
 tor());%0A
-            
+%09%09%09
 %7D catch 
@@ -1083,32 +1083,20 @@
 on e) %7B%0A
-                
+%09%09%09%09
 e.printS
@@ -1112,45 +1112,24 @@
 ();%0A
-            %7D%0A%0A        %7D%0A%0A    %7D%0A%0A    
+%09%09%09%7D%0A%0A%09%09%7D%0A%0A%09%7D%0A%0A%09
 publ
@@ -1210,20 +1210,17 @@
 l(10);%0A%0A
-    
+%09
 public s
@@ -1256,34 +1256,19 @@
 ) %7B%0A
-        try %7B%0A            
+%09%09try %7B%0A%09%09%09
 Serv
@@ -1306,28 +1306,40 @@
 ket(
-5678);%0A%0A            
+Integer.parseInt(args%5B0%5D));%0A%0A%09%09%09
 Syst
@@ -1436,28 +1436,19 @@
 rt());%0A%0A
-            
+%09%09%09
 while (t
@@ -1454,32 +1454,20 @@
 true) %7B%0A
-                
+%09%09%09%09
 Socket c
@@ -1492,32 +1492,20 @@
 ept();%0A%0A
-                
+%09%09%09%09
 TCP_WORK
@@ -1526,97 +1526,40 @@
 mit(
-%0A                        new TCPWorker(client)%0A                );%0A%0A            %7D%0A        
+new TCPWorker(client));%0A%0A%09%09%09%7D%0A%09%09
 %7D ca
@@ -1584,20 +1584,11 @@
 ) %7B%0A
-            
+%09%09%09
 e.pr
@@ -1608,22 +1608,13 @@
 ();%0A
-        %7D%0A    
+%09%09%7D%0A%09
 %7D%0A%0A%7D

Update MultiThreadedTCPServer.java