public synchronized Executor getExecutor() { if (executor == null) { Thread currentThread = Thread.currentThread(); if (currentThread instanceof ForkJoinWorkerThread) { executor = ((ForkJoinWorkerThread)currentThread).getPool(); } else { executor = threadLocalExecutor.get(); } } return executor; }
String result = StreamEx.of("a", "b", "c") .parallel(fjp) .peek(x -> System.out.println( ((ForkJoinWorkerThread) Thread.currentThread()).getPool())) .collect(Collectors.joining());