### Question:
AcknowledgedCounterGenerator extends CounterGenerator { public void acknowledge(int value) { final int currentSlot = (value & WINDOW_MASK); if (window[currentSlot] == true) { throw new RuntimeException("Too many unacknowledged insertion keys."); } window[currentSlot] = true; if (lock.tryLock()) { try { int beforeFirstSlot = (limit & WINDOW_MASK); int index; for (index = limit + 1; index != beforeFirstSlot; ++index) { int slot = (index & WINDOW_MASK); if (!window[slot]) { break; } window[slot] = false; } limit = index - 1; } finally { lock.unlock(); } } } AcknowledgedCounterGenerator(int countstart); @Override Integer lastValue(); void acknowledge(int value);  }### Answer:
@Test public void testIncrementPastIntegerMaxValue() { final long toTry = AcknowledgedCounterGenerator.WINDOW_SIZE * 3; AcknowledgedCounterGenerator generator = new AcknowledgedCounterGenerator(Integer.MAX_VALUE - 1000); Random rand = new Random(System.currentTimeMillis()); BlockingQueue<Integer> pending = new ArrayBlockingQueue<Integer>(1000); for (long i = 0; i < toTry; ++i) { int value = generator.nextValue(); while (!pending.offer(value)) { Integer first = pending.poll(); if (rand.nextBoolean()) { generator.acknowledge(first); } else { Integer second = pending.poll(); pending.add(first); generator.acknowledge(second); } } } }