Java Phaser register() Method

The register() method of Phaser class is used to add the new un-arrived party in the phaser. This method generates no effect and returns the negative value if the phasor is terminated.

Syntax

Return

It returns the phase number of registered parties.

Throws

IllegalStateException - this Exception is thrown when the number of registered parties is more.

Example 1

Test it Now

Output:

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

Example 2

Test it Now

Output:

Phaser Object is register...
Initial Phase count is 0
Thread is sleeping
Thread-0 arrived
Thread-2 arrived
Final Phase count after arrival of Thread is 1
Thread-3 arrived
Thread-1 arrived

Next TopicJava Phaser




Latest Courses