Chapter 2. Managing Lots of Threads – Executors
When you implement a simple concurrent application, you create and execute a thread per concurrent task. This approach can have some important issues. Since Java version 5, the Java concurrency API includes the executor framework to improve the performance of concurrent applications with a lot of concurrent tasks. In this chapter, we will cover the following:
- An introduction to executors
- The first example – the k-nearest neighbors algorithm
- The second example – concurrency in a client/server environment
An introduction to executors
The basic mechanism to implement a concurrent application in Java is:
- A class that implements the Runnable interface: This is the code you want to implement in a concurrent ...