public Optional<Long> claimNextId() {
        long nextId = producerIdCounter.getAndIncrement();
        if (nextId > lastProducerId()) {
            return Optional.empty();
        }
        return Optional.of(nextId);
    }
@Test
    public void testClaimNextId() throws Exception {
        for (int i = 0; i < 50; i++) {
            ProducerIdsBlock block = new ProducerIdsBlock(0, 1, 1);
            CountDownLatch latch = new CountDownLatch(1);
            AtomicLong counter = new AtomicLong(0);
            CompletableFuture.runAsync(() -> {
                Optional<Long> pid = block.claimNextId();
                counter.addAndGet(pid.orElse(0L));
                latch.countDown();
            });
            Optional<Long> pid = block.claimNextId();
            counter.addAndGet(pid.orElse(0L));
            assertTrue(latch.await(1, TimeUnit.SECONDS));
            assertEquals(1, counter.get());
        }
    }