/** * Equivalent to {@code runConcurrently(30, SECONDS, tasks)} */ protected void runConcurrently(ExceptionRunnable... tasks) throws Exception { runConcurrently(30, TimeUnit.SECONDS, tasks); }
/** * Equivalent to {@code runConcurrently(30, SECONDS, tasks)} */ protected void runConcurrently(Callable<?>... tasks) throws Exception { runConcurrently( Arrays.stream(tasks).<ExceptionRunnable>map(task -> task::call).toArray(ExceptionRunnable[]::new)); }
/** * This will run two or more tasks concurrently. * * It synchronizes before starting at approximately the same time by ensuring they all start before * allowing the tasks to proceed. * * @param tasks The tasks to run * @throws InterruptedException Thrown if this thread is interrupted * @throws ExecutionException Thrown if one of the callables throws any kind of Throwable. The * thrown Throwable will be wrapped by this exception * @throws TimeoutException If one of the tasks doesn't complete within the timeout */ protected void runConcurrently(long timeout, TimeUnit timeUnit, Callable<?>... tasks) throws Exception { runConcurrently(timeout, timeUnit, Arrays.stream(tasks).<ExceptionRunnable>map(task -> task::call) .toArray(ExceptionRunnable[]::new)); }