The first step to work with the Executor framework is to create an object of the
ThreadPoolExecutor class. You can use the four constructors provided by that class or use a factory class named
Executors that creates
ThreadPoolExecutor. Once you have an executor, you can send
Callable objects to be executed.
In this recipe, you will learn how these two operations implement an example that will simulate a web server processing requests from various clients.
You should read the Creating and running a thread recipe in Chapter 1 to learn the basic mechanism of thread creation in Java. You can compare both mechanisms and select the best one depending on the problem.
The example of this recipe has been ...