Java Phaser arriveAndDeregister() Method

The arriveAndDeregister () method is of Phaser class. This method deregisters the current phaser on its arrival, without waiting for the other phaser to arrive which are in the queue.

Syntax:

Return:

It returns the arrival 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
Final Phase count after arrival of Thread is 0
Thread-0 arrived
Thread Arrive And Deregister...

Example 2

Test it Now

Output:

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

Next TopicJava Phaser




Latest Courses