Java Phaser arriveAndAwaitAdvance() Method

The arriveAndAwaitAdvance() method returns the arrival phase number, or the negative current phase (if terminated). Using this method, the current phaser arrives, and other phaser waits in the queue.

Syntax:

Return:

It returns current phaser number.

Throws:

IllegalStateException - This Exception is thrown when the number of unarrived parties is negative.

Example 1

Test it Now

Output:

Thread is sleeping
Thread-0 arrived
Thread-1 arrived
Final Phase count after arrival of Thread is 0
Thread-2 arrived
Thread-4 arrived
Thread-5 arrived
Thread-3 arrived

Example 2

Test it Now

Output:

Phaser Object is register...
Initial Phase count is 0
Thread-0 arrived

Next TopicJava Phaser




Latest Courses