@Test void testSingleThread() { AtomicCycle cycle = new AtomicCycle(2); assertThat(cycle.incrementAndGet(), is(0)); assertThat(cycle.incrementAndGet(), is(1)); assertThat(cycle.incrementAndGet(), is(2)); assertThat(cycle.incrementAndGet(), is(0)); assertThat(cycle.incrementAndGet(), is(1)); assertThat(cycle.incrementAndGet(), is(2)); assertThat(cycle.incrementAndGet(), is(0)); }
int incrementAndGet() { return atomicInteger.accumulateAndGet(maxIndex, (current, max) -> (current + 1) % max); }
AtomicCycle { int incrementAndGet() { return atomicInteger.accumulateAndGet(maxIndex, (current, max) -> (current + 1) % max); } }
AtomicCycle { int incrementAndGet() { return atomicInteger.accumulateAndGet(maxIndex, (current, max) -> (current + 1) % max); } AtomicCycle(int maxIndex); }
AtomicCycle { int incrementAndGet() { return atomicInteger.accumulateAndGet(maxIndex, (current, max) -> (current + 1) % max); } AtomicCycle(int maxIndex);  }
AtomicCycle { int incrementAndGet() { return atomicInteger.accumulateAndGet(maxIndex, (current, max) -> (current + 1) % max); } AtomicCycle(int maxIndex);   }