public static List<Closure> joinAll(final List<Task> tasks, long timeoutMillis) throws InterruptedException,
                                                                                   TimeoutException {
        final List<Closure> closures = new ArrayList<>(tasks.size());
        for (final Task t : tasks) {
            final long start = System.nanoTime();
            closures.add(t.join(timeoutMillis));
            timeoutMillis -= TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start);
            if (timeoutMillis <= 0) {
                throw new TimeoutException("joined timeout");
            }
        }
        return closures;
    }
Waiting for all tasks to complete with a timeout millis.

@param tasks         task list
@param timeoutMillis the maximum millis to wait
@return the closure list in the tasks
@throws InterruptedException if the current thread is interrupted while waiting
@throws TimeoutException if timeout
@since 1.3.1
jraft-core/src/main/java/com/alipay/sofa/jraft/entity/Task.java