Java Phaser getPhase() Methods

The getPhase() method of Phaser class is used to return the number of current phase number. The maximum value of Phase number is Integer.MAX_VALUE. It returns the negative value if the phase number is negative.

Syntax

Return

It returns the current phase number. Otherwise, it returns the negative number if terminated.

Example 1

Test it Now

Output:

Initial Phase count is 0
Thread is sleeping
Thread-0 arrived
Thread-1 arrived
Thread-2 arrived
Thread-3 arrived
Thread-4 arrived
Thread-5 arrived
Thread-6 arrived
Thread-7 arrived
Thread-8 arrived
Final Phase count after arrival of Thread is 1
Thread-10 arrived
Thread-9 arrived

Example 2

Test it Now

Output:

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

Next TopicJava Phaser




Latest Courses