diff options
author | belugabehr <12578579+belugabehr@users.noreply.github.com> | 2021-06-30 09:08:34 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-30 09:08:34 -0400 |
commit | 5cada6a3202a0e5e11ff36dfbb925f0e037bf856 (patch) | |
tree | 7e205c6b0f67df0baee48938ea21591f1edeb10c /lib/java/src | |
parent | 598ee9864beb51af18ee467e34340d4c9d462b6e (diff) | |
download | thrift-5cada6a3202a0e5e11ff36dfbb925f0e037bf856.tar.gz |
THRIFT-5433: Add Counter To Thread Name of TThreadPoolServer
Client: Java
Patch: David Mollitor
Diffstat (limited to 'lib/java/src')
-rw-r--r-- | lib/java/src/org/apache/thrift/server/TThreadPoolServer.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java index 01749b98a..e19041568 100644 --- a/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java +++ b/lib/java/src/org/apache/thrift/server/TThreadPoolServer.java @@ -26,6 +26,7 @@ import java.util.concurrent.SynchronousQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import org.apache.thrift.TException; import org.apache.thrift.TProcessor; @@ -100,11 +101,12 @@ public class TThreadPoolServer extends TServer { private static ExecutorService createDefaultExecutorService(Args args) { return new ThreadPoolExecutor(args.minWorkerThreads, args.maxWorkerThreads, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), new ThreadFactory() { + final AtomicLong count = new AtomicLong(); @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setDaemon(true); - thread.setName("TThreadPoolServer WorkerProcess-%d"); + thread.setName(String.format("TThreadPoolServer WorkerProcess-%d", count.getAndIncrement())); return thread; } }); |