configurable service thread name prefix
Motivation: If netty used as part of application, should be a way to prefix service thread name to easy distinguish such threads (for example, used in IntelliJ Platform) Modifications: Introduce system property io.netty.serviceThreadPrefix Result: ThreadDeathWatcher thread has a readable name "Netty threadDeathWatcher-2-1" if io.netty.serviceThreadPrefix set to "Netty"
This commit is contained in:
parent
8ecfd58714
commit
fd810e7178
@ -19,6 +19,8 @@ package io.netty.util;
|
||||
import io.netty.util.concurrent.DefaultThreadFactory;
|
||||
import io.netty.util.internal.MpscLinkedQueueNode;
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.netty.util.internal.SystemPropertyUtil;
|
||||
import io.netty.util.internal.logging.InternalLogger;
|
||||
import io.netty.util.internal.logging.InternalLoggerFactory;
|
||||
|
||||
@ -40,14 +42,22 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
public final class ThreadDeathWatcher {
|
||||
|
||||
private static final InternalLogger logger = InternalLoggerFactory.getInstance(ThreadDeathWatcher.class);
|
||||
private static final ThreadFactory threadFactory =
|
||||
new DefaultThreadFactory(ThreadDeathWatcher.class, true, Thread.MIN_PRIORITY);
|
||||
private static final ThreadFactory threadFactory;
|
||||
|
||||
private static final Queue<Entry> pendingEntries = PlatformDependent.newMpscQueue();
|
||||
private static final Watcher watcher = new Watcher();
|
||||
private static final AtomicBoolean started = new AtomicBoolean();
|
||||
private static volatile Thread watcherThread;
|
||||
|
||||
static {
|
||||
String poolName = "threadDeathWatcher";
|
||||
String serviceThreadPrefix = SystemPropertyUtil.get("io.netty.serviceThreadPrefix");
|
||||
if (!StringUtil.isNullOrEmpty(serviceThreadPrefix)) {
|
||||
poolName = serviceThreadPrefix + poolName;
|
||||
}
|
||||
threadFactory = new DefaultThreadFactory(poolName, true, Thread.MIN_PRIORITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules the specified {@code task} to run when the specified {@code thread} dies.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user