@Test
public void testMultiSubmitters()
{

    final AsyncSemaphore<Runnable> asyncSemaphore = new AsyncSemaphore<>(2, executor, executor::submit);
    final AtomicInteger count = new AtomicInteger();
    final AtomicInteger concurrency = new AtomicInteger();
    final CountDownLatch startLatch = new CountDownLatch(1);
    final CountDownLatch completionLatch = new CountDownLatch(100);
    for (int i = 0; i < 100; i++) {
        executor.execute(() -> {
            Uninterruptibles.awaitUninterruptibly(startLatch, 1, TimeUnit.MINUTES);
            asyncSemaphore.submit(() -> {
                count.incrementAndGet();
                int currentConcurrency = concurrency.incrementAndGet();
                assertLessThanOrEqual(currentConcurrency, 2);
                Uninterruptibles.sleepUninterruptibly(1, TimeUnit.MILLISECONDS);
                concurrency.decrementAndGet();
                completionLatch.countDown();
            });
        });
    }
    // Start the submitters;
    startLatch.countDown();
    // Wait for completion
    Uninterruptibles.awaitUninterruptibly(completionLatch, 1, TimeUnit.MINUTES);
    Assert.assertEquals(count.get(), 100);
}