Class MoreThreads


  • @ParametersAreNonnullByDefault
    public final class MoreThreads
    extends Object
    Static utility methods related to Thread instances.
    • Method Detail

      • newThreadFactory

        @Nonnull
        public static ThreadFactory newThreadFactory​(@Nullable
                                                     String prefix)
        Creates a new ThreadFactory that creates daemon threads with a defined prefixed name.
        Parameters:
        prefix - the prefix of the name of created threads; if null the default name will be used
        Returns:
        a new thread factory
        See Also:
        Executors.defaultThreadFactory()
      • executeAtExit

        public static void executeAtExit​(Runnable task)
        Adds a shutdown hook that will execute the task when the application will exit.
        Parameters:
        task - the task to execute
        Throws:
        NullPointerException - if the task is null