O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition 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

How to do it...

Follow these steps to implement the example:

  1. Create a class named MyPhaser and specify that it extends from the Phaser class:
        public class MyPhaser extends Phaser {
  1. Override the onAdvance() method. According to the value of the phase attribute, we call it a different auxiliary method. If the phase attribute is equal to zero, you have to call the studentsArrived() method. If the phase is equal to one, you have to call the finishFirstExercise() method. If the phase is equal to two, you have to call the finishSecondExercise() method. Finally, if the phase is equal to three, you have to call the finishExam() method. Otherwise, return the true value to indicate that phaser has terminated:
        @Override  protected boolean onAdvance(int ...

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