Java Phaser getParent() Method

The getParent() method of Phaser class is used to get the parent of the current phaser. It returns null there is no parent of the current phaser.

Syntax:

Return:

it returns the parent of current phaser

Example 1

Test it Now

Output:

Thread is sleeping
Thread-0 arrived
Parent Phaser: java.util.concurrent.Phaser@2b71e323[phase = 0 parties = 11 arrived = 1]

Example 2

Test it Now

Output:

Thread-1 arrived
Parent Phaser: java.util.concurrent.Phaser@2eaa3bae[phase = 0 parties = 11 arrived = 1]
Thread-4 arrived
Thread-3 arrived
Parent Phaser: java.util.concurrent.Phaser@2eaa3bae[phase = 0 parties = 11 arrived = 3]
Thread-0 arrived
Thread-2 arrived
Parent Phaser: java.util.concurrent.Phaser@2eaa3bae[phase = 0 parties = 11 arrived = 5]
Parent Phaser: java.util.concurrent.Phaser@2eaa3bae[phase = 0 parties = 11 arrived = 4]
Thread-5 arrived
Parent Phaser: java.util.concurrent.Phaser@2eaa3bae[phase = 0 parties = 11 arrived = 2]
Parent Phaser: java.util.concurrent.Phaser@2eaa3bae[phase = 0 parties = 11 arrived = 6]

Next TopicJava Phaser




Latest Courses