public void awaitNextIncrements ( long nextIncrements ) throws InterruptedException { if ( nextIncrements <= 0 ) { throw new IllegalArgumentException ( "nextIncrements is not positive: " + nextIncrements ) ; } if ( nextIncrements > MAX_COUNT / 4 ) { throw new UnsupportedOperationException ( "Couldn't wait for so many increments: " + nextIncrements ) ; } awaitCount ( ( sync . getCount ( ) + nextIncrements ) & MAX_COUNT ) ; }
Somewhat loosely defined wait for next N increments because the starting point is not defined from the Java Memory Model perspective .