Class SimpleThreadFactory

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

    public class SimpleThreadFactory
    extends java.lang.Object
    implements java.util.concurrent.ThreadFactory
    Simple implementation of a thread factory.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean daemon
      Whether to set daemon mode.
      private static java.util.concurrent.atomic.AtomicInteger threadIdx
      The thread index counter, used for assigning unique thread ids.
      private java.lang.String threadNamePrefix
      The thread name prefix.
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleThreadFactory​(java.lang.String threadNamePrefix, boolean daemon)
      Constructor.
    • Method Summary

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

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

      • threadNamePrefix

        private final java.lang.String threadNamePrefix
        The thread name prefix.
      • threadIdx

        private static final java.util.concurrent.atomic.AtomicInteger threadIdx
        The thread index counter, used for assigning unique thread ids.
      • daemon

        private final boolean daemon
        Whether to set daemon mode.
    • Constructor Detail

      • SimpleThreadFactory

        SimpleThreadFactory​(java.lang.String threadNamePrefix,
                            boolean daemon)
        Constructor.
        Parameters:
        threadNamePrefix - prefix for created threads.
        daemon - create daemon threads?
    • Method Detail

      • newThread

        public java.lang.Thread newThread​(java.lang.Runnable runnable)
        New thread.
        Specified by:
        newThread in interface java.util.concurrent.ThreadFactory
        Parameters:
        runnable - the runnable
        Returns:
        the thread