Runnables { public static void runParallel(Runnable... runnables) { Flux<Runnable> stream = Flux.just(runnables); runParallel(stream); }  static void runParallel(Runnable... runnables); static void runParallel(Flux<Runnable> runnables);  }
@Test void shouldActuallyRunThings() { AtomicBoolean sideEffect = new AtomicBoolean(false); Runnables.runParallel(() -> sideEffect.set(true)); assertThat(sideEffect).isTrue(); }
@Test void shouldActuallyRunInParallel() throws InterruptedException { int parallel = 2; CountDownLatch countDownLatch = new CountDownLatch(parallel); Runnable runnable = countDownLatch::countDown; Runnables.runParallel(Flux.range(0, 2).map(i -> runnable)); assertThat(countDownLatch.await(2, TimeUnit.MINUTES)).isTrue(); }