How To Naming ForkJoinPool
How To Naming ForkJoinPool
How To Naming ForkJoinPool
How To Naming ForkJoinPool
try (ForkJoinPool pool = new ForkJoinPool(Runtime.getRuntime().availableProcessors(),
new NamedForkJoinWorkerThreadFactory(“MyForkJoinThreadWorker”), null, false)) {
}
private record NamedForkJoinWorkerThreadFactory(
@NotNull String prefix) implements ForkJoinPool.ForkJoinWorkerThreadFactory {
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
ForkJoinWorkerThread thread = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
thread.setName(prefix + "-" + System.currentTimeMillis());
return thread;
}
}