Package org.jboss.netty.util
Class ThreadRenamingRunnable
- java.lang.Object
-
- org.jboss.netty.util.ThreadRenamingRunnable
-
- All Implemented Interfaces:
Runnable
public class ThreadRenamingRunnable extends Object implements Runnable
ARunnable
that changes the current thread name and reverts it back when its execution ends. To change the default thread names set by Netty, usesetThreadNameDeterminer(ThreadNameDeterminer)
.
-
-
Constructor Summary
Constructors Constructor Description ThreadRenamingRunnable(Runnable runnable, String proposedThreadName)
ThreadRenamingRunnable(Runnable runnable, String proposedThreadName, ThreadNameDeterminer determiner)
Creates a new instance which wraps the specifiedrunnable
and changes the thread name to the specified thread name when the specifiedrunnable
is running.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ThreadNameDeterminer
getThreadNameDeterminer()
Returns theThreadNameDeterminer
which overrides the proposed new thread name.void
run()
static void
setThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer)
Sets theThreadNameDeterminer
which overrides the proposed new thread name.
-
-
-
Constructor Detail
-
ThreadRenamingRunnable
public ThreadRenamingRunnable(Runnable runnable, String proposedThreadName, ThreadNameDeterminer determiner)
Creates a new instance which wraps the specifiedrunnable
and changes the thread name to the specified thread name when the specifiedrunnable
is running.
-
-
Method Detail
-
getThreadNameDeterminer
public static ThreadNameDeterminer getThreadNameDeterminer()
Returns theThreadNameDeterminer
which overrides the proposed new thread name.
-
setThreadNameDeterminer
public static void setThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer)
Sets theThreadNameDeterminer
which overrides the proposed new thread name. Please note that the specifiedThreadNameDeterminer
affects only newThreadRenamingRunnable
s; 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.
-
-