List of usage examples for java.util.concurrent Phaser forceTermination
public void forceTermination()
From source file:Main.java
public static void main(String[] args) { Phaser phaser = new Phaser() { protected boolean onAdvance(int phase, int parties) { System.out.println("Inside onAdvance(): phase = " + phase + ", Registered Parties = " + parties); // Do not terminate the phaser by returning false return false; }/*from w w w . jav a2 s . co m*/ }; // Register the self (the "main" thread) as a party phaser.register(); System.out.println("#1: isTerminated():" + phaser.isTerminated()); phaser.arriveAndDeregister(); // Trigger another phase advance phaser.register(); phaser.arriveAndDeregister(); System.out.println("#2: isTerminated():" + phaser.isTerminated()); phaser.forceTermination(); System.out.println("#3: isTerminated():" + phaser.isTerminated()); }