class ParallelUtil {

    public static <T extends BaseStream<?, T>, R> R parallelStream(T data, int concurrency, Function<T, R> fn) {
        ForkJoinPool pool = getFJPoolWithConcurrency(concurrency);
        try {
            return pool.submit(() -> fn.apply(data.parallel())).get();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            pool.shutdown();
        }
    }

    private  ParallelUtil();

}