Concurrency
In the previous chapter, we explored the nuances of streamlined data manipulation and parallelized operations that utilize the power of modern multi-core processors. This was already a little introduction to this chapter’s topic: concurrency!
Concurrency allows applications to perform multiple tasks at the same time. This makes the system more efficient. Any available resources can be utilized more efficiently, and this leads to overall improved performance. In order to do multiple things at the same in Java, we need to know quite a bit. That’s what this chapter is for!
Here’s what we’ll cover:
- A definition of concurrency
- Working with threads
- Atomic classes
- The synchronized keyword
- Using locks for exclusive thread access
- Concurrent collections
- Using
ExecutorService
- Common threading problems and how to avoid them
This is often a dreaded (or threaded?) topic, especially for new developers, so don...