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 ...

Get Mastering Concurrency Programming with Java 9 - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.