O'Reilly logo

Mastering Concurrency Programming with Java 9 - Second Edition by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The executor

Now that we have the auxiliary classes of the executor, we have to implement the executor itself. We have implemented the ServerExecutor class for this purpose. It extends the ThreadPoolExecutor class and has some internal attributes, as follows:

  • startTimes: This is a ConcurrentHashMap to store the start date of every task. The key of the class will be the ServerTask object (a Runnable object), and the value will be a Date object.
  • executionStatistics: This is a ConcurrentHashMap to store the statistics of use per user. The key will be the username and the value will be an ExecutorStatistics object.
  • CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, and KEEP_ALIVE_TIME: These are constants to define the characteristics of the executor.
  • REJECTED_TASK_CONTROLLER ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required