Class DaemonThreadFactory

  • All Implemented Interfaces:
    java.util.concurrent.ThreadFactory

    public class DaemonThreadFactory
    extends java.lang.Object
    implements java.util.concurrent.ThreadFactory
    A simple thread factory that decorates Executors.defaultThreadFactory() and sets all created threads to be daemon threads.
    Author:
    Einar M R Rosenvinge
    • Constructor Summary

      Constructors 
      Constructor Description
      DaemonThreadFactory()
      Creates a deamon thread factory that creates threads with the default names provided by Executors.defaultThreadFactory().
      DaemonThreadFactory​(java.lang.String prefix)
      Creates a deamon thread factory that creates threads with the default names provided by Executors.defaultThreadFactory() prepended by the specified prefix.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getPrefix()  
      java.lang.Thread newThread​(java.lang.Runnable runnable)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DaemonThreadFactory

        public DaemonThreadFactory()
        Creates a deamon thread factory that creates threads with the default names provided by Executors.defaultThreadFactory().
      • DaemonThreadFactory

        public DaemonThreadFactory​(java.lang.String prefix)
        Creates a deamon thread factory that creates threads with the default names provided by Executors.defaultThreadFactory() prepended by the specified prefix.
        Parameters:
        prefix - the thread name prefix to use
    • Method Detail

      • getPrefix

        public java.lang.String getPrefix()
      • newThread

        public java.lang.Thread newThread​(java.lang.Runnable runnable)
        Specified by:
        newThread in interface java.util.concurrent.ThreadFactory