How it works...
This exercise simulates the realization of an exam that has three exercises. All the students have to finish one exercise before they can start the next one. To implement this synchronization requirement, we use the Phaser class; however, in this case, you implemented your own phaser, extending the original class to override the onAdvance() method.
This method is called by Phaser before making a phase change and waking up all the threads that were sleeping in the arriveAndAwaitAdvance() method. The method is invoked by the last thread that finishes a phase as part of the code of the arriveAndAwaitAdvance() method. This method receives the number of the actual phase as parameters, where 0 is the number of the first phase and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access