@Test
public void testCounter()
{

    int maxThreads = 1;
    BoundedExecutor boundedExecutor = new BoundedExecutor(executorService, maxThreads); // Enforce single thread
    int stageTasks = 100_000;
    int totalTasks = stageTasks * 2;
    AtomicInteger counter = new AtomicInteger();
    CountDownLatch initializeLatch = new CountDownLatch(maxThreads);
    CountDownLatch startLatch = new CountDownLatch(1);
    CountDownLatch completeLatch = new CountDownLatch(totalTasks);
    // Pre-loaded tasks
    for (int i = 0; i < stageTasks; i++) {
        boundedExecutor.execute(() -> {
            try {
                initializeLatch.countDown();
                Uninterruptibles.awaitUninterruptibly(startLatch); // Wait for the go signal
                // Intentional distinct read and write calls
                int initialCount = counter.get();
                counter.set(initialCount + 1);
            }
            finally {
                completeLatch.countDown();
            }
        });
    }
    assertTrue(Uninterruptibles.awaitUninterruptibly(initializeLatch, 1, TimeUnit.MINUTES)); // Wait for pre-load tasks to initialize
    startLatch.countDown(); // Signal go for stage1 threads
    // Concurrently submitted tasks
    for (int i = 0; i < stageTasks; i++) {
        boundedExecutor.execute(() -> {
            try {
                // Intentional distinct read and write calls
                int initialCount = counter.get();
                counter.set(initialCount + 1);
            }
            finally {
                completeLatch.countDown();
            }
        });
    }
    assertTrue(Uninterruptibles.awaitUninterruptibly(completeLatch, 1, TimeUnit.MINUTES)); // Wait for tasks to complete
    assertEquals(counter.get(), totalTasks);
}