Package org.jboss.netty.util
Class ThreadRenamingRunnable
- java.lang.Object
-
- org.jboss.netty.util.ThreadRenamingRunnable
-
- All Implemented Interfaces:
java.lang.Runnable
public class ThreadRenamingRunnable extends java.lang.Object implements java.lang.RunnableARunnablethat changes the current thread name and reverts it back when its execution ends. To change the default thread names set by Netty, usesetThreadNameDeterminer(ThreadNameDeterminer).
-
-
Field Summary
Fields Modifier and Type Field Description private ThreadNameDeterminerdeterminerprivate static InternalLoggerloggerprivate java.lang.StringproposedThreadNameprivate java.lang.Runnablerunnableprivate static ThreadNameDeterminerthreadNameDeterminer
-
Constructor Summary
Constructors Constructor Description ThreadRenamingRunnable(java.lang.Runnable runnable, java.lang.String proposedThreadName)ThreadRenamingRunnable(java.lang.Runnable runnable, java.lang.String proposedThreadName, ThreadNameDeterminer determiner)Creates a new instance which wraps the specifiedrunnableand changes the thread name to the specified thread name when the specifiedrunnableis running.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.StringgetNewThreadName(java.lang.String currentThreadName)static ThreadNameDeterminergetThreadNameDeterminer()Returns theThreadNameDeterminerwhich overrides the proposed new thread name.voidrun()static voidsetThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer)Sets theThreadNameDeterminerwhich overrides the proposed new thread name.
-
-
-
Field Detail
-
logger
private static final InternalLogger logger
-
threadNameDeterminer
private static volatile ThreadNameDeterminer threadNameDeterminer
-
determiner
private final ThreadNameDeterminer determiner
-
runnable
private final java.lang.Runnable runnable
-
proposedThreadName
private final java.lang.String proposedThreadName
-
-
Constructor Detail
-
ThreadRenamingRunnable
public ThreadRenamingRunnable(java.lang.Runnable runnable, java.lang.String proposedThreadName, ThreadNameDeterminer determiner)Creates a new instance which wraps the specifiedrunnableand changes the thread name to the specified thread name when the specifiedrunnableis running.
-
ThreadRenamingRunnable
public ThreadRenamingRunnable(java.lang.Runnable runnable, java.lang.String proposedThreadName)
-
-
Method Detail
-
getThreadNameDeterminer
public static ThreadNameDeterminer getThreadNameDeterminer()
Returns theThreadNameDeterminerwhich overrides the proposed new thread name.
-
setThreadNameDeterminer
public static void setThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer)
Sets theThreadNameDeterminerwhich overrides the proposed new thread name. Please note that the specifiedThreadNameDetermineraffects only newThreadRenamingRunnables; the existing instances are not affected at all. Therefore, you should make sure to call this method at the earliest possible point (i.e. before any Netty worker thread starts) for consistent thread naming. Otherwise, you might see the default thread names and the new names appear at the same time in the full thread dump.
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
getNewThreadName
private java.lang.String getNewThreadName(java.lang.String currentThreadName)
-
-