@Test public void countDownShouldBeUnchangedAsZeroNegativeTest() { AtomicInteger atomicCounter = new AtomicInteger( 0 ); assertFalse( countDownToZero( atomicCounter ) ); assertThat( atomicCounter.get(), is( 0 ) ); }
@SuppressWarnings( "checkstyle:emptyforiteratorpad" ) public static boolean countDownToZero( AtomicInteger counter ) { for (;;) { int c = counter.get(); if ( c > 0 ) { int newCounter = c - 1; if ( counter.compareAndSet( c, newCounter ) ) { return newCounter == 0; } } else { return false; } } }
ConcurrencyUtils { @SuppressWarnings( "checkstyle:emptyforiteratorpad" ) public static boolean countDownToZero( AtomicInteger counter ) { for (;;) { int c = counter.get(); if ( c > 0 ) { int newCounter = c - 1; if ( counter.compareAndSet( c, newCounter ) ) { return newCounter == 0; } } else { return false; } } } }
ConcurrencyUtils { @SuppressWarnings( "checkstyle:emptyforiteratorpad" ) public static boolean countDownToZero( AtomicInteger counter ) { for (;;) { int c = counter.get(); if ( c > 0 ) { int newCounter = c - 1; if ( counter.compareAndSet( c, newCounter ) ) { return newCounter == 0; } } else { return false; } } } private  ConcurrencyUtils(); }
ConcurrencyUtils { @SuppressWarnings( "checkstyle:emptyforiteratorpad" ) public static boolean countDownToZero( AtomicInteger counter ) { for (;;) { int c = counter.get(); if ( c > 0 ) { int newCounter = c - 1; if ( counter.compareAndSet( c, newCounter ) ) { return newCounter == 0; } } else { return false; } } } private  ConcurrencyUtils(); @SuppressWarnings( "checkstyle:emptyforiteratorpad" ) static boolean countDownToZero( AtomicInteger counter ); }
ConcurrencyUtils { @SuppressWarnings( "checkstyle:emptyforiteratorpad" ) public static boolean countDownToZero( AtomicInteger counter ) { for (;;) { int c = counter.get(); if ( c > 0 ) { int newCounter = c - 1; if ( counter.compareAndSet( c, newCounter ) ) { return newCounter == 0; } } else { return false; } } } private  ConcurrencyUtils(); @SuppressWarnings( "checkstyle:emptyforiteratorpad" ) static boolean countDownToZero( AtomicInteger counter );  }