Interview Focused : Phaser Class in Java

1) Use Phaser if you need to wait for threads to arrive before you start or proceed a set of tasks.
2) A Phaser is reusable synchronization barrier, similar in functionality to CyclicBarrier but CountDownLatch does not support reusability.
3) In Phaser Tasks may be registered at any time, on the go or dynamically.
4) Like a CyclicBarrier, a Phaser may be repeatedly awaited.
5) Methods arrive() and arriveAndDeregister() record arrival.

6) Unlike similar constructions using CyclicBarrier, method awaitAdvance continues to wait even if the waiting thread is interrupted.
7) Upon termination, all synchronization methods immediately return without waiting for advance, as indicated by a negative return value.
8) Whenever the number of registered parties becomes zero as the result of an invocation of arriveAndDeregister(), the child phaser is deregistered from its parent.(Tiering).
9) At any given moment there are getRegisteredParties() parties in total, of which getArrivedParties() have arrived at the current phase (getPhase()).
10) The ‘Phaser’ concept and name was coined in this whitepaper by a team at Rice University. The name comes from the construct’s phase-ordering and deadlock-avoidance properties.

Comments

Popular posts from this blog

Java Interview : Threads

Spring Framework Interview Notes : Part Two Wiring

Card Dealer In Java in Less than 5 minutes