The Implementation of Blocking IO, Non-blocking IO and Netty
The server only use one thread to receive and handle client sockets. If current socket is still in processing, the subsequent socket will be blocked.
The server will open a separate thread to process each new socket so that the multiple socket could process concurrently.
The server will create a thread pool to reduce the overhead of thread creation and destruction.
Add each socket events to array, and continuously loop to check and process it even if this socket didn't send any message
Initialize a Selector to receive the socket events. The selector will start processing only when there are some socket registered.