Java Phaser bulkRegister() Method

The bulkRegister() method is of Phaser class. This method Adds the given number of new unarrived parties to this phaser.

Syntax

Parameters

parties - It is the number of parties to add in advance to the next phase.

Return

It returns the number of arrival phase to which this registration applied.

Throws

IllegalStateException - It throws exception if tried to register more than the maximum number of parties.

IllegalArgumentException - It throws exception if parties less than 0.

Example 1

Test it Now

Output:

Phasecount is 0
Unarrived parties to current phaser : 0
Thread-0 arrived
Unarrived parties to current phaser : 0
Thread-1 arrived
Thread-2 arrived
Unarrived parties to current phaser : 0
Unarrived parties to current phaser : 0
Unarrived parties to current phaser : 0
Thread-4 arrived
Thread-3 arrived
Phasecount is 0

Example 2

Test it Now

Output:

Phasecount is 0
Unarrived parties to current phaser : 0
Unarrived parties to current phaser : 0
Thread-0 arrived
Thread-1 arrived
Phasecount is 0

Next TopicJava Phaser




Latest Courses