@Override public boolean join(long timeoutMillis) throws InterruptedException { return Joinable.joinAll(timeoutMillis, elements); }
/** * Helper for joining on all provided {@link Joinable} instances, using {@code timeoutMillis} as * the upper bound on the join timeout. * * @param timeoutMillis The time to wait. {@code 0} means wait forever. * @param joinables The instances to join on. * @return True if <em>all</em> instances were joined on successfully within the timeout, false if at * least one join timed out. * @throws InterruptedException If the thread is interrupted. */ static boolean joinAll(long timeoutMillis, Joinable... joinables) throws InterruptedException { return joinAll(timeoutMillis, Arrays.asList(joinables)); }
@Override public Joinable terminate() { final List<Joinable> joinables = elements.stream().map(t -> t.terminate()).collect(Collectors.toList()); return timeoutMillis -> Joinable.joinAll(timeoutMillis, joinables); }