Class NamedThreadFactory

    • Constructor Detail

      • NamedThreadFactory

        public NamedThreadFactory​(java.lang.String namePrefix)
    • Method Detail

      • updateThreadName

        @Deprecated
        public static java.lang.String updateThreadName​(@NotNull
                                                        java.lang.String newDetails)
        Update current thread name to include new details
        Parameters:
        newDetails - Thread name details, should not include timestamp and should not include previous thread name
        Returns:
        Previous thread name
      • newThread

        @NotNull
        public java.lang.Thread newThread​(@NotNull
                                          java.lang.Runnable r)
        Specified by:
        newThread in interface java.util.concurrent.ThreadFactory
      • getThreadDump

        public java.lang.String getThreadDump()
        Deprecated.
        Returns:
        complete thread dump
      • executeWithNewThreadName

        public static void executeWithNewThreadName​(@NotNull
                                                    java.lang.String newDetails,
                                                    @NotNull
                                                    java.lang.Runnable action)
        Inserts newDetails to the thread name and executes given action. Restores original thread name when action finishes.
        Parameters:
        newDetails - new details to set in thread name
        action - action to execute
        Since:
        7.1.4
      • executeWithNewThreadName

        public static <T> T executeWithNewThreadName​(@NotNull
                                                     java.lang.String newDetails,
                                                     @NotNull
                                                     java.util.concurrent.Callable<T> action)
                                              throws java.lang.Exception
        Parameters:
        newDetails - new details to set in thread name
        action - action to execute
        Throws:
        java.lang.Exception
        Since:
        8.1
      • executeWithNewThreadNameFuncThrow

        public static <T,​E extends java.lang.Throwable> T executeWithNewThreadNameFuncThrow​(@NotNull
                                                                                                  java.lang.String newDetails,
                                                                                                  @NotNull
                                                                                                  FuncThrow<T,​E> function)
                                                                                           throws E extends java.lang.Throwable
        Same as executeWithNewThreadName(String, Runnable) but for arbitrary thrown exception
        Parameters:
        newDetails - new details to set in thread name
        function - function to execute
        Throws:
        E extends java.lang.Throwable
        Since:
        2017.1
      • executeWithNewThreadNameActionThrow

        public static <E extends java.lang.Throwable> void executeWithNewThreadNameActionThrow​(@NotNull
                                                                                               java.lang.String newDetails,
                                                                                               @NotNull
                                                                                               ActionThrow<E> action)
                                                                                        throws E extends java.lang.Throwable
        Same as executeWithNewThreadName(String, Runnable) but for arbitrary thrown exception
        Parameters:
        newDetails - new details to set in thread name
        action - action to execute
        Throws:
        E extends java.lang.Throwable
        Since:
        2022.1
      • patchThreadName

        @NotNull
        public static jetbrains.buildServer.util.Disposable patchThreadName​(@NotNull
                                                                            java.lang.String newDetails)
        Parameters:
        newDetails - new details to add to thread name
        Returns:
        Disposable which should be disposed manually to return original thread name
        Since:
        8.1
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object