There's more...

The Phaser class provides other methods related to the change of phase. These methods are as follows:

  • arrive(): This method notifies the Phaser class that one participant has finished the actual phase but it should not wait for the rest of the participants to continue with their execution. Be careful with the utilization of this method because it doesn't synchronize with other threads.
  • awaitAdvance(int phase): This method puts the current thread to sleep until all the participants of the phaser parameter have finished the current phase, that is, if the number we pass as the parameter is equal to the actual phase of phaser. If the parameter and the actual phase of phaser aren't equal, the method  ends its execution.
  • awaitAdvanceInterruptibly(int ...

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.