src/main/java/com/github/phantomthief/concurrent/MoreFutures.java
@Nonnull
    public static <F extends Future<V>, V> Map<F, V> tryWait(@Nonnull Iterable<F> futures,
            @Nonnegative long timeout, @Nonnull TimeUnit unit)
            throws TryWaitFutureUncheckedException {
        checkNotNull(futures);
        checkArgument(timeout > 0);
        checkNotNull(unit);
        return tryWait(futures, timeout, unit, it -> it, TryWaitFutureUncheckedException::new);
    }
@Nonnull
    public static <F extends Future<V>, V> Map<F, V> tryWait(@Nonnull Iterable<F> futures,
            @Nonnegative long timeout, @Nonnull TimeUnit unit)
            throws TryWaitFutureUncheckedException {
        checkNotNull(futures);
        checkArgument(timeout > 0);
        checkNotNull(unit);
        return tryWait(futures, timeout, unit, it -> it, TryWaitFutureUncheckedException::new);
    }
A typical usage:
{@code <pre>
// a fail-safe example
List<Future<User>> list = doSomeAsyncTasks();
Map<Future<User>, User> success;
try {
success = tryWait(list, 1, SECONDS);
} catch (TryWaitUncheckedException e) {
success = e.getSuccess(); // there are still some success
}

// a fail-fast example
List<Future<User>> list = doSomeAsyncTasks();
// don't try/catch the exception it throws.
Map<Future<User>, User> success; = tryWait(list, 1, SECONDS);
</pre>}

@throws TryWaitUncheckedException if not all calls are successful.