More precisely, this code wrongly consider the phase "0" to be a clue that the phaser is currently stopped, whereas only strictly negative values indicate a closed phaser:
int phaseBeforeUnarrivedPartiesCheck = phaser.getPhase();
if ( phaser.getUnarrivedParties() > 0 ) {
phaser.awaitAdvanceInterruptibly( phaseBeforeUnarrivedPartiesCheck );
}
We should use >= 0 instead |