public class NamePreservingRunnable
extends java.lang.Object
implements java.lang.Runnable
Runnable wrapper that preserves the name of the thread after the runnable is
complete (for Runnables that change the name of the Thread they use.)| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
LOGGER |
private java.lang.String |
newName
The runnable name
|
private java.lang.Runnable |
runnable
The runnable task
|
| Constructor and Description |
|---|
NamePreservingRunnable(java.lang.Runnable runnable,
java.lang.String newName)
Creates a new instance of NamePreservingRunnable.
|
| Modifier and Type | Method and Description |
|---|---|
void |
run()
Run the runnable after having renamed the current thread's name
to the new name.
|
private void |
setName(java.lang.Thread thread,
java.lang.String name)
Wraps
Thread.setName(String) to catch a possible Exceptions such as
SecurityException in sandbox environments, such as applets |
private static final org.slf4j.Logger LOGGER
private final java.lang.String newName
private final java.lang.Runnable runnable
public NamePreservingRunnable(java.lang.Runnable runnable,
java.lang.String newName)
runnable - The underlying runnablenewName - The runnable's namepublic void run()
run in interface java.lang.Runnableprivate void setName(java.lang.Thread thread,
java.lang.String name)
Thread.setName(String) to catch a possible Exceptions such as
SecurityException in sandbox environments, such as applets