i2ptunnel: Add thread number to server thread names

like we already do for clients, to make debugging easier
This commit is contained in:
zzz
2023-11-21 08:50:34 -05:00
parent a08f59d42f
commit 761967ed4b

View File

@@ -28,6 +28,7 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicLong;
import net.i2p.I2PException;
import net.i2p.I2PAppContext;
@@ -733,6 +734,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
/** just to set the name and set Daemon */
private static class CustomThreadFactory implements ThreadFactory {
private final String _name;
private final AtomicLong _executorThreadCount = new AtomicLong();
public CustomThreadFactory(String name) {
_name = name;
@@ -740,7 +742,7 @@ public class I2PTunnelServer extends I2PTunnelTask implements Runnable {
public Thread newThread(Runnable r) {
Thread rv = Executors.defaultThreadFactory().newThread(r);
rv.setName(_name);
rv.setName(_name + ' ' + _executorThreadCount.incrementAndGet());
rv.setDaemon(true);
return rv;
}