Class DefaultThreadFactory

  • All Implemented Interfaces:
    java.util.concurrent.ThreadFactory, ThreadFactory
    Direct Known Subclasses:
    LazyThreadFactory

    public class DefaultThreadFactory
    extends java.lang.Object
    implements ThreadFactory
    Thread factory mainly responsible for naming of threads. Can be replaced by user. If use_numbering is set, a thread THREAD will be called THREAD-1, THREAD-2, and so on.

    If a pattern has been set (through setPattern()), then the cluster name and local address will also be added, e.g. THREAD-5,MyCluster,192.168.1.5:63754 or THREAD,MyCluster,192.168.1.5:63754

    If includeClusterName and includeLocalAddress are both false, and clusterName is set, then we assume we have a shared transport, and therefore print shared=clusterName.

    Author:
    Vladimir Blagojevic, Bela Ban
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultThreadFactory​(java.lang.String baseName, boolean createDaemons)  
      DefaultThreadFactory​(java.lang.String baseName, boolean createDaemons, boolean use_numbering)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected java.lang.String getNewThreadName​(java.lang.String base_name, java.lang.String addr, java.lang.String cluster_name)  
      protected java.lang.String getThreadName​(java.lang.String base_name, java.lang.Thread thread, java.lang.String addr, java.lang.String cluster_name)  
      <T extends DefaultThreadFactory>
      T
      log​(Log l)  
      java.lang.Thread newThread​(java.lang.Runnable r)  
      java.lang.Thread newThread​(java.lang.Runnable r, java.lang.String name)  
      protected java.lang.Thread newThread​(java.lang.Runnable r, java.lang.String name, java.lang.String addr, java.lang.String cluster_name)  
      void renameThread​(java.lang.String base_name, java.lang.Thread thread)  
      void renameThread​(java.lang.String base_name, java.lang.Thread thread, java.lang.String addr, java.lang.String cluster_name)
      Names a thread according to base_name, cluster name and local address.
      void renameThread​(java.lang.Thread thread)  
      void setAddress​(java.lang.String address)  
      void setClusterName​(java.lang.String channelName)  
      void setIncludeClusterName​(boolean includeClusterName)  
      void setPattern​(java.lang.String pattern)  
      boolean useFibers()
      Deprecated, for removal: This API element is subject to removal in a future version.
      <T extends DefaultThreadFactory>
      T
      useFibers​(boolean f)
      Deprecated, for removal: This API element is subject to removal in a future version.
      boolean useVirtualThreads()  
      <T extends DefaultThreadFactory>
      T
      useVirtualThreads​(boolean f)  
      • Methods inherited from class java.lang.Object

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

      • baseName

        protected final java.lang.String baseName
      • createDaemons

        protected final boolean createDaemons
      • use_numbering

        protected final boolean use_numbering
      • counter

        protected short counter
      • includeClusterName

        protected boolean includeClusterName
      • clusterName

        protected java.lang.String clusterName
      • includeLocalAddress

        protected boolean includeLocalAddress
      • address

        protected java.lang.String address
      • use_virtual_threads

        protected boolean use_virtual_threads
      • log

        protected Log log
    • Constructor Detail

      • DefaultThreadFactory

        public DefaultThreadFactory​(java.lang.String baseName,
                                    boolean createDaemons)
      • DefaultThreadFactory

        public DefaultThreadFactory​(java.lang.String baseName,
                                    boolean createDaemons,
                                    boolean use_numbering)
    • Method Detail

      • setPattern

        public void setPattern​(java.lang.String pattern)
        Specified by:
        setPattern in interface ThreadFactory
      • setClusterName

        public void setClusterName​(java.lang.String channelName)
        Specified by:
        setClusterName in interface ThreadFactory
      • setAddress

        public void setAddress​(java.lang.String address)
        Specified by:
        setAddress in interface ThreadFactory
      • useFibers

        @Deprecated(forRemoval=true)
        public boolean useFibers()
        Deprecated, for removal: This API element is subject to removal in a future version.
      • useFibers

        @Deprecated(forRemoval=true)
        public <T extends DefaultThreadFactory> T useFibers​(boolean f)
        Deprecated, for removal: This API element is subject to removal in a future version.
      • useVirtualThreads

        public boolean useVirtualThreads()
      • newThread

        public java.lang.Thread newThread​(java.lang.Runnable r,
                                          java.lang.String name)
        Specified by:
        newThread in interface ThreadFactory
      • newThread

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

        protected java.lang.Thread newThread​(java.lang.Runnable r,
                                             java.lang.String name,
                                             java.lang.String addr,
                                             java.lang.String cluster_name)
      • renameThread

        public void renameThread​(java.lang.String base_name,
                                 java.lang.Thread thread)
        Specified by:
        renameThread in interface ThreadFactory
      • renameThread

        public void renameThread​(java.lang.String base_name,
                                 java.lang.Thread thread,
                                 java.lang.String addr,
                                 java.lang.String cluster_name)
        Names a thread according to base_name, cluster name and local address. If includeClusterName and includeLocalAddress are null, but cluster_name is set, then we assume we have a shared transport and name the thread shared=clusterName. In the latter case, clusterName points to the singleton_name of TP.
        Parameters:
        base_name -
        thread -
        addr -
        cluster_name -
      • renameThread

        public void renameThread​(java.lang.Thread thread)
      • getThreadName

        protected java.lang.String getThreadName​(java.lang.String base_name,
                                                 java.lang.Thread thread,
                                                 java.lang.String addr,
                                                 java.lang.String cluster_name)
      • getNewThreadName

        protected java.lang.String getNewThreadName​(java.lang.String base_name,
                                                    java.lang.String addr,
                                                    java.lang.String cluster_name)