Class NamedSequenceThreadFactory

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

    public final class NamedSequenceThreadFactory
    extends java.lang.Object
    implements java.util.concurrent.ThreadFactory
    Thread factory for providing meaningful names to the created threads.
    All threads created through this factory will be given a unique identifier based on a sequence counter.
    E.g. providing the name MyThread will yield threads called MyThread-n , where n is the sequence counter for created threads.
    The counter starts at 1, thus the naming series will be threadName-[1-n]
    Since:
    1.2
    • Constructor Summary

      Constructors 
      Constructor Description
      NamedSequenceThreadFactory​(java.lang.String threadName)
      Create the factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Thread newThread​(java.lang.Runnable runnable)
      Creates a new thread using the provided name and sequence counter.
      • Methods inherited from class java.lang.Object

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

      • NamedSequenceThreadFactory

        public NamedSequenceThreadFactory​(java.lang.String threadName)
        Create the factory.
        Parameters:
        threadName - The name of the threads to be created.
        Since:
        1.2
    • Method Detail

      • newThread

        public java.lang.Thread newThread​(java.lang.Runnable runnable)
        Creates a new thread using the provided name and sequence counter.
        E.g. threadName-nnn
        Specified by:
        newThread in interface java.util.concurrent.ThreadFactory
        Since:
        1.2