Class ConfigurableThreadFactory

  • All Implemented Interfaces:
    ThreadFactory

    public class ConfigurableThreadFactory
    extends Object
    implements ThreadFactory
    Thread factory that creates threads for use by a ThreadPoolExecutor. The factory can be configured to customise the names, priority and daemon status of created threads.
    • Constructor Detail

      • ConfigurableThreadFactory

        public ConfigurableThreadFactory​(String namePrefix,
                                         int priority,
                                         boolean daemon)
        Parameters:
        namePrefix - The String prefix used to assign identifiers to created threads.
        priority - The initial priority for created threads.
        daemon - Whether or not created threads should be daemon threads or user threads. The JVM exits when the only threads running are all daemon threads.
      • ConfigurableThreadFactory

        public ConfigurableThreadFactory​(String namePrefix,
                                         int priority,
                                         boolean daemon,
                                         Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
        Parameters:
        namePrefix - The String prefix used to assign identifiers to created threads.
        priority - The initial priority for created threads.
        daemon - Whether or not created threads should be daemon threads or user threads. The JVM exits when the only threads running are all daemon threads.
        uncaughtExceptionHandler - A strategy for dealing with uncaught exceptions.
    • Method Detail

      • newThread

        public Thread newThread​(Runnable runnable)
        Creates a new thread configured according to this factory's parameters.
        Specified by:
        newThread in interface ThreadFactory
        Parameters:
        runnable - The runnable to be executed by the new thread.
        Returns:
        The created thread.