O'Reilly logo

Mastering Concurrency Programming with Java 8 by Javier Fernández González

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Running Tasks Divided into Phases – The Phaser Class

The most important element in a concurrent API is the synchronization mechanisms it offers to the programmer. Synchronization is the coordination of two or more tasks to get the desired result. You can synchronize the execution of two or more tasks, when they have to be executed in a predefined order, or synchronize the access to a shared resource, when only one thread at a time can execute a fragment of code or modify a block of memory. Java 8 concurrency API provides a lot of synchronization mechanisms from the basic synchronized keyword or the Lock interface and their implementations to protect a critical section to the more advanced CyclicBarrier or CountDownLatch classes that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required