private void runAll ( RunNode next ) { for ( ; ; ) { final RunNode current = next ; run ( current ) ; if ( ( next = current . get ( ) ) == null ) { // try advance, if we get null test if ( last . compareAndSet ( current , null ) ) { return ; // end-of-queue: we're done. } else { //noinspection StatementWithEmptyBody while ( ( next = current . get ( ) ) == null ) { // Thread.onSpinWait(); in Java 9 } } } } }
Runs all the RunNodes starting with next