Concurrency in Java: Multithreading, Parallelism, and Asynchrony in Practice
300 pages
English
PDF
4.5

Concurrency in Java: Multithreading, Parallelism, and Asynchrony in Practice

Concurrency in Java: Multithreading, Parallelism, and Asynchrony in Practice

Author:

Year:

Summary:

Modern applications must be fast and responsive. But writing correct multithreaded code is one of the most difficult tasks in programming. Data races, deadlocks, visibility and performance issues await the developer at every turn. The book "Concurrency in Java" is a practical guide that will help you master all aspects of parallel programming in Java: from classic low-level tools to modern high-level abstractions and experimental features of Project Loom.



What is this book about?

The book is structured on the principle of "from simple to complex." You will start with the basics: what a thread is, how to create and start it, and what problems arise when working with shared data. Then you will dive into the world of synchronization: synchronized, volatile, java.util.concurrent.locks, and atomic classes. Next, you will study thread pools (ExecutorService, ForkJoinPool), learn how to efficiently manage tasks and avoid "thread leaks." Dedicated chapters cover:

  • CompletableFuture and asynchronous programming — building non-blocking data processing pipelines.
  • Streams and parallel collections — safe use of Stream.parallel() and ConcurrentHashMap.
  • Testing multithreaded code — utilities, patterns (Awaitility, Thread Weaver), and common mistakes.
  • Project Loom (virtual threads) — a new approach to concurrency that promises to simplify writing scalable server applications.


Who is this book for?

The publication will be useful for:

  • Junior developers who are already familiar with Java syntax and want to understand how multithreading works.
  • Middle developers who encounter bugs in production and want to systematize their knowledge.
  • Architects and Team Leads making decisions about choosing a concurrency model for high-load systems.


What will you learn?

After reading, you will be able to:

  • Properly design multithreaded architectures, avoiding deadlocks and race conditions.
  • Choose the right tool for the task: from ReentrantLock to Phaser and CompletableFuture.
  • Configure thread pools for specific scenarios (CPU-bound, I/O-bound).
  • Write safe and testable parallel algorithms.
  • Understand the internal workings of the JVM and JMM (Java Memory Model) at a level sufficient for debugging complex problems.

Each chapter contains code examples that can be downloaded and run, as well as exercises for self-assessment. The book is written in a lively style, without excessive academicism, but with a deep dive into technical details.



"Concurrency in Java" is not just a reference book, but a desktop guide you will return to again and again when designing high-performance and reliable Java applications.

Recommendations