Controlling phase change in concurrent-phased tasks

The Phaser class provides a method that is executed each time phaser changes the phase. It's the onAdvance() method. It receives two parameters: the number of the current phases and the number of registered participants. It returns a Boolean value false if Phaser continues its execution or the value true if Phaser has finished and has to enter the termination state.

The default implementation of this method returns true if the number of registered participants is zero, and false otherwise. But you can modify this behavior if you extend the Phaser class and override this method. Normally, you will be interested in doing this when you have to execute some actions when you advance from one ...

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.