Class WithThreadName

  • All Implemented Interfaces:
    AutoCloseable

    public final class WithThreadName
    extends Object
    implements AutoCloseable
    Utility to temporarily append some information to the name of the current thread. This is helpful for making thread dumps more readable and informative: stack trace elements do not contain any information about object identity.
    • Constructor Detail

      • WithThreadName

        public WithThreadName​(String suffix)
        Sets the current thread’s name.
        Parameters:
        suffix - text to append to the original name
    • Method Detail

      • close

        public void close()
        Restores the original name.
        Specified by:
        close in interface AutoCloseable