Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.Phaser; public class PhaserGetRegisteredPartiesExample1 { public static void main(String[] args) throws InterruptedException { int i, j; Phaser p = new Phaser(); p.register(); int pc = p.getPhase(); System.out.println("Phasecount is "+pc); new PhaserGetRegisteredPartiesExample1().testPhaser(p); Thread.sleep(5000); pc = p.getPhase(); System.out.println("Phasecount is "+pc); j=p.getRegisteredParties(); System.out.println("Arrived Registered Parties:"+j); } private void testPhaser(final Phaser phaser) { new Thread(){ @Override public void run() { System.out.println(Thread.currentThread().getName()+" arrived"); } }.start(); } }
Output