Class DaemonThreadFactory

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

    public final class DaemonThreadFactory
    extends java.lang.Object
    implements java.util.concurrent.ThreadFactory
    Creates new daemon Thread.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.ThreadGroup group  
      private java.lang.String namePrefix  
      private static java.util.concurrent.atomic.AtomicInteger POOL_NUMBER  
      private java.util.concurrent.atomic.AtomicInteger threadNumber  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private DaemonThreadFactory()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Thread newDaemonThread​(java.lang.Runnable r)  
      static java.lang.Thread newDaemonThread​(java.lang.Runnable r, java.lang.String name)  
      static java.util.concurrent.ThreadFactory newDaemonThreadFactory()
      Should be used by thread pools.
      static java.util.concurrent.ThreadFactory newDaemonThreadFactory​(java.lang.String name)  
      java.lang.Thread newThread​(java.lang.Runnable r)  
      • Methods inherited from class java.lang.Object

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

      • POOL_NUMBER

        private static final java.util.concurrent.atomic.AtomicInteger POOL_NUMBER
      • threadNumber

        private final java.util.concurrent.atomic.AtomicInteger threadNumber
      • group

        private final java.lang.ThreadGroup group
      • namePrefix

        private final java.lang.String namePrefix
    • Constructor Detail

      • DaemonThreadFactory

        private DaemonThreadFactory()
    • Method Detail

      • newThread

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

        public static java.util.concurrent.ThreadFactory newDaemonThreadFactory()
        Should be used by thread pools.
        Returns:
        new instance of ThreadFactory where each thread is daemon
      • newDaemonThreadFactory

        public static java.util.concurrent.ThreadFactory newDaemonThreadFactory​(java.lang.String name)
      • newDaemonThread

        public static java.lang.Thread newDaemonThread​(java.lang.Runnable r)
      • newDaemonThread

        public static java.lang.Thread newDaemonThread​(java.lang.Runnable r,
                                                       java.lang.String name)