Class NamePreservingRunnable

java.lang.Object
org.apache.mina.util.NamePreservingRunnable
All Implemented Interfaces:
Runnable

public class NamePreservingRunnable extends Object implements Runnable
A 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.)
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • newName

      private final String newName
      The runnable name
    • runnable

      private final Runnable runnable
      The runnable task
  • Constructor Details

    • NamePreservingRunnable

      public NamePreservingRunnable(Runnable runnable, String newName)
      Creates a new instance of NamePreservingRunnable.
      Parameters:
      runnable - The underlying runnable
      newName - The runnable's name
  • Method Details

    • run

      public void run()
      Run the runnable after having renamed the current thread's name to the new name. When the runnable has completed, set back the current thread name back to its origin.
      Specified by:
      run in interface Runnable
    • setName

      private void setName(Thread thread, String name)
      Wraps Thread.setName(String) to catch a possible Exceptions such as SecurityException in sandbox environments, such as applets