Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.Phaser; public class PhaserAwaitAdvanceExample2 { public static void main(String[] args) throws InterruptedException { Phaser p = new Phaser(); p.register(); System.out.println("Phaser Object is register..."); for(int i=1; i<=5; i++) { new PhaserAwaitAdvanceExample2().test(p); if(i==3) { System.out.println("Thread awaitAdvance : "+ p.awaitAdvance(3)); } } } private void test(final Phaser p) { new Thread(){ @Override public void run() { System.out.println(Thread.currentThread().getName()+" arrived"); } }.start(); } }
Output