Created
January 7, 2023 11:22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ak.app; | |
import javax.annotation.Nonnull; | |
import java.util.concurrent.ForkJoinPool; | |
import java.util.logging.Logger; | |
import java.util.stream.IntStream; | |
public class CommonPoolTest { | |
private CommonPoolTest() { | |
} | |
public static void main(@Nonnull String[] args) { | |
try (ForkJoinPool custom = new ForkJoinPool(2)) { | |
Integer integer = custom.submit(() -> IntStream.range(0, 3).unordered().parallel() | |
.peek(i -> Logger.getAnonymousLogger().info(() -> "Thread [%s] peek: %d%n".formatted(Thread.currentThread().getName(), i))) | |
.sum()).join(); | |
Logger.getAnonymousLogger().info(integer::toString); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Be Aware of ForkJoinPool#commonPool()