Skip to content

Commit

Permalink
Use native ThreadFactory creator instead of custom one (#783)
Browse files Browse the repository at this point in the history
JDK21 introduced `Thread.ofPlatform()...factory()` - no need to rely on a custom implementation
  • Loading branch information
pivovarit authored Oct 9, 2023
1 parent b945f67 commit 04ce124
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/main/java/com/pivovarit/collectors/Dispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ private static Runnable withFinally(Runnable task, Runnable finisher) {
private static ThreadPoolExecutor newLazySingleThreadExecutor() {
return new ThreadPoolExecutor(0, 1,
0L, TimeUnit.MILLISECONDS,
new SynchronousQueue<>(),
task -> {
Thread thread = Executors.defaultThreadFactory().newThread(task);
thread.setName("parallel-collector-" + thread.getName());
thread.setDaemon(false);
return thread;
});
new LinkedBlockingQueue<>(),
Thread.ofPlatform()
.name("parallel-collectors-dispatcher-", 0)
.daemon(false)
.factory());
}

static final class InterruptibleCompletableFuture<T> extends CompletableFuture<T> {
Expand Down

0 comments on commit 04ce124

Please sign in to comment.