Skip to content

Commit de8b593

Browse files
authored
Use internal Dispatcher thread factory to launch Dispatcher threads (#959)
1 parent 1089d72 commit de8b593

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/pivovarit/collectors/Dispatcher.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.concurrent.LinkedBlockingQueue;
1010
import java.util.concurrent.RejectedExecutionException;
1111
import java.util.concurrent.Semaphore;
12+
import java.util.concurrent.ThreadFactory;
1213
import java.util.concurrent.atomic.AtomicBoolean;
1314
import java.util.function.Function;
1415
import java.util.function.Supplier;
@@ -25,6 +26,8 @@ final class Dispatcher<T> {
2526
private final CompletableFuture<Void> completionSignaller = new CompletableFuture<>();
2627
private final BlockingQueue<Runnable> workingQueue = new LinkedBlockingQueue<>();
2728

29+
private final ThreadFactory dispatcherThreadFactory = Thread::startVirtualThread;
30+
2831
private final Executor executor;
2932
private final Semaphore limiter;
3033

@@ -72,7 +75,7 @@ static <T> Dispatcher<T> virtual(int permits) {
7275

7376
void start() {
7477
if (!started.getAndSet(true)) {
75-
Thread.startVirtualThread(() -> {
78+
dispatcherThreadFactory.newThread(() -> {
7679
try {
7780
while (true) {
7881
try {

0 commit comments

Comments
 (0)