DelayedFiring implements Runnable { @Override public void run() { ensureNotOver(); LOGGER.debug("Requesting delayed event firing."); try { if (all.isEmpty()) { return; } LOGGER.trace("Triggering firing."); triggersEventFiring.await(); LOGGER.trace("Waiting for firing to complete."); CompletableFuture.allOf(all.toArray(new CompletableFuture[0])) .join(); } catch (final InterruptedException | BrokenBarrierException e) { Thread.currentThread() .interrupt(); throw new IllegalStateException("Failed firing events in a transaction.", e); } finally { isOver.set(true); LOGGER.debug("Firing over."); } }  boolean isPending(); CompletableFuture delay(final Runnable runnable); void cancel(); @Override void run();  }
@Test void runningDisablesInstance() { final DelayedFiring d = new DelayedFiring(); d.run(); assertCancelled(d); }