Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.Phaser; public class JavaPhaserGetParentExample1 { public static void main(String[] args) throws InterruptedException { Phaser p = new Phaser(10); p.register(); Phaser pc = p.getParent(); System.out.println("Thread is sleeping"); Thread.sleep(5000); new JavaPhaserGetParentExample1().test(p); } void test(final Phaser p) { new Thread(){ @Override public void run() { System.out.println(Thread.currentThread().getName()+" arrived" ); p.arrive(); System.out.println("Parent Phaser: "+p); } }.start(); } }
Output