Concurrent programming has always been a difficult task. It might sound easy, but it is a source of many hard-to-solve problems. In this chapter, we will show you different ways of incorporating concurrency and some best practices, such as immutability, which will help in creating better, concurrent applications. We will also discuss the implementation of some commonly used patterns, such as divide-conquer and publish-subscribe, using the constructs provided by Java. We will cover the following recipes:
- Using the basic element of concurrency - thread
- Different synchronization approaches
- Immutability as a means to achieve concurrency
- Using concurrent collections
- Using the executor service to execute ...