In this chapter, we presented two examples that explored the advanced characteristics of executors. In the first example, we continued with the client/server example of Chapter 3, Managing Lots of Threads - Executors. We have implemented our own executor extending the
ThreadPoolExecutor class to execute tasks by priority and to measure the executing time of tasks per user. We also included a new command to allow the cancellation of tasks.
In the second example, we explained how to use the
ScheduledThreadPoolExecutor class to execute periodic tasks. We implemented two versions of a news reader. The first one showed how to use the basic functionality of the
ScheduledExecutorService, and the second one showed how to override the behavior of the
ScheduledExecutorService class to, for example, change the delay time between the two executions of a task.
In the next chapter, you will learn how to execute
Executor tasks that return a result. If you extend the
Thread class or implement the...