private static JoinableClosure castToJoinalbe(final Closure closure) {
        if (closure instanceof JoinableClosure) {
            return (JoinableClosure) closure;
        }
        throw new UnsupportedOperationException("Unsupported join");
    }
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