public class ThreadRenamingRunnable
extends java.lang.Object
implements java.lang.Runnable
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)
.构造器和说明 |
---|
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 specified
runnable
and changes the thread name to the specified thread name when the
specified runnable is running. |
限定符和类型 | 方法和说明 |
---|---|
static ThreadNameDeterminer |
getThreadNameDeterminer()
Returns the
ThreadNameDeterminer which overrides the proposed
new thread name. |
void |
run() |
static void |
setThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer)
Sets the
ThreadNameDeterminer which overrides the proposed new
thread name. |
public ThreadRenamingRunnable(java.lang.Runnable runnable, java.lang.String proposedThreadName, ThreadNameDeterminer determiner)
runnable
and changes the thread name to the specified thread name when the
specified runnable
is running.public ThreadRenamingRunnable(java.lang.Runnable runnable, java.lang.String proposedThreadName)
public static ThreadNameDeterminer getThreadNameDeterminer()
ThreadNameDeterminer
which overrides the proposed
new thread name.public static void setThreadNameDeterminer(ThreadNameDeterminer threadNameDeterminer)
ThreadNameDeterminer
which overrides the proposed new
thread name. Please note that the specified ThreadNameDeterminer
affects only new ThreadRenamingRunnable
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.public void run()
run
在接口中 java.lang.Runnable