Modify the thread name in the thread pool.

pull/161/head
chen.ma 3 years ago
parent b226b8b5b9
commit 3cf2bbc988

@ -1,6 +1,5 @@
package com.github.dynamic.threadpool.config.toolkit;
import cn.hutool.core.thread.ThreadFactoryBuilder;
import com.github.dynamic.threadpool.common.executor.ExecutorFactory;
import java.util.concurrent.ScheduledExecutorService;
@ -17,9 +16,7 @@ public class ConfigExecutor {
private static final ScheduledExecutorService LONG_POLLING_EXECUTOR = ExecutorFactory.Managed
.newSingleScheduledExecutorService("default group",
ThreadFactoryBuilder.create()
.setNamePrefix("io.dynamic.threadPool.config.LongPolling")
.build());
r -> new Thread(r, "long-polling"));
public static void executeLongPolling(Runnable runnable) {
LONG_POLLING_EXECUTOR.execute(runnable);

@ -50,7 +50,7 @@ public class ClientWorker {
this.executor = Executors.newScheduledThreadPool(1, r -> {
Thread t = new Thread(r);
t.setName("io.dynamic.threadPool.client.Worker.executor");
t.setName("client.worker.executor");
t.setDaemon(true);
return t;
});
@ -58,7 +58,7 @@ public class ClientWorker {
int threadSize = Runtime.getRuntime().availableProcessors();
this.executorService = Executors.newScheduledThreadPool(threadSize, r -> {
Thread t = new Thread(r);
t.setName("io.dynamic.threadPool.client.Worker.longPolling.executor");
t.setName("client.long.polling.executor");
t.setDaemon(true);
return t;
});

Loading…
Cancel
Save