The key of this example is the Server class. This class creates and uses ThreadPoolExecutor to execute tasks.
The first important point is the creation of ThreadPoolExecutor in the constructor of the Server class. The ThreadPoolExecutor class has four different constructors, but due to their complexity, the Java concurrency API provides the Executors class to construct executors and other related objects. Although you can create ThreadPoolExecutor directly using one of its constructors, it's recommended that you use the Executors class.
In this case, you created a cached thread pool using the newFixedThreadPool() method of the Executors class in order to create the executor. This method creates an executor with the maximum ...