void () { int count = 1000; AtomicInteger executionCount = new AtomicInteger(); Executor countingExecutor = r -> AppExecutorUtil.getAppExecutorService().execute(() -> { executionCount.incrementAndGet(); r.run(); }); List<CancellablePromise<?>> submissions = new ArrayList<>(); WriteAction.run(() -> { for (int i = 0; i < count; i++) { submissions.add(ReadAction.nonBlocking(() -> {}).coalesceBy(this).submit(countingExecutor)); } }); for (CancellablePromise<?> submission : submissions) { waitForPromise(submission); } assertTrue(executionCount.toString(), executionCount.get() <= 2); }