How it works...

In this recipe, we implemented a phased task in the Task class. This phased task has three phases and uses a Phaser interface to synchronize with other Task objects. The main class launches three tasks, and when these tasks execute their respective phases, it prints information about the status of the phaser object to the console. We used the following methods to get the status of the phaser object:

  • getPhase(): This method returns the actual phase of a phaser object
  • getRegisteredParties(): This method returns the number of tasks that use a phaser object as a mechanism of synchronization
  • getArrivedParties(): This method returns the number of tasks that have arrived at the end of the actual phase
  • getUnarrivedParties(): This method returns the number of tasks that haven't yet arrived at the end of the actual phase

The following screenshot shows part of the output of the program:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.216.7