Package org.jboss.netty.util
Class ThreadRenamingRunnable
java.lang.Object
org.jboss.netty.util.ThreadRenamingRunnable
- All Implemented Interfaces:
Runnable
A
Runnable that changes the current thread name and reverts it back
when its execution ends. To change the default thread names set by Netty,
use setThreadNameDeterminer(ThreadNameDeterminer).-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ThreadNameDeterminerprivate static final InternalLoggerprivate final Stringprivate final Runnableprivate static ThreadNameDeterminer -
Constructor Summary
ConstructorsConstructorDescriptionThreadRenamingRunnable(Runnable runnable, String proposedThreadName) ThreadRenamingRunnable(Runnable runnable, 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
Modifier and TypeMethodDescriptionprivate StringgetNewThreadName(String currentThreadName) static ThreadNameDeterminerReturns theThreadNameDeterminerwhich overrides the proposed new thread name.voidrun()static voidsetThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer) Sets theThreadNameDeterminerwhich overrides the proposed new thread name.
-
Field Details
-
logger
-
threadNameDeterminer
-
determiner
-
runnable
-
proposedThreadName
-
-
Constructor Details
-
ThreadRenamingRunnable
public ThreadRenamingRunnable(Runnable runnable, 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
-
-
Method Details
-
getThreadNameDeterminer
Returns theThreadNameDeterminerwhich overrides the proposed new thread name. -
setThreadNameDeterminer
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() -
getNewThreadName
-