From 66a1fde223ee34574396d826890baee63617ac8a Mon Sep 17 00:00:00 2001 From: Krzysiekigry Date: Wed, 20 Nov 2024 19:56:03 +0100 Subject: [PATCH] feat(nats-connection): implement named executor thread factories --- .../io/nats/client/impl/NatsConnection.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/nats/client/impl/NatsConnection.java b/src/main/java/io/nats/client/impl/NatsConnection.java index 72ff04a6f..eb0c13c62 100644 --- a/src/main/java/io/nats/client/impl/NatsConnection.java +++ b/src/main/java/io/nats/client/impl/NatsConnection.java @@ -157,8 +157,22 @@ class NatsConnection implements Connection { timeTraceLogger.trace("creating executors"); this.executor = options.getExecutor(); - this.callbackRunner = Executors.newSingleThreadExecutor(); - this.connectExecutor = Executors.newSingleThreadExecutor(); + this.callbackRunner = Executors.newSingleThreadExecutor(new ThreadFactory() { + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r); + t.setName("nats-callback-runner"); + return t; + } + }); + this.connectExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() { + @Override + public Thread newThread(Runnable r) { + Thread t = new Thread(r); + t.setName("nats-connect-executor"); + return t; + } + }); timeTraceLogger.trace("creating reader and writer"); this.reader = new NatsConnectionReader(this);