org.jgroups.util

## Class DefaultThreadFactory

- java.lang.Object
- - org.jgroups.util.DefaultThreadFactory

All Implemented Interfaces:
  java.util.concurrent.ThreadFactory, ThreadManager

Direct Known Subclasses:
  LazyThreadFactory

    public class DefaultThreadFactory
    extends java.lang.Object
    implements ThreadFactory, ThreadManager

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

Author:
  Vladimir Blagojevic, Bela Ban

### Field Summary

Fields
`protected java.lang.String` `address`
`protected java.lang.String` `baseName`
`protected java.lang.String` `clusterName`
`protected short` `counter`
`protected boolean` `createDaemons`
`protected java.lang.ThreadGroup` `group`
`protected boolean` `includeClusterName`
`protected boolean` `includeLocalAddress`
`protected ThreadDecorator` `threadDecorator`
`protected boolean` `use_numbering`

### Constructor Summary

Constructors
Constructor and Description
`DefaultThreadFactory(java.lang.ThreadGroup group, java.lang.String baseName, boolean createDaemons)`
`DefaultThreadFactory(java.lang.ThreadGroup group, java.lang.String baseName, boolean createDaemons, boolean use_numbering)`

### Method Summary

Methods
`ThreadDecorator` `getThreadDecorator()` Gets the ThreadDecorator associated with this manager.
`java.lang.Thread` `newThread(java.lang.Runnable r)`
`java.lang.Thread` `newThread(java.lang.Runnable r, java.lang.String name)`
`java.lang.Thread` `newThread(java.lang.ThreadGroup group, java.lang.Runnable r, java.lang.String name)`
`protected java.lang.Thread` `newThread(java.lang.ThreadGroup group, 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)`
`void` `renameThread(java.lang.Thread thread)`
`protected void` `renameThread(java.lang.Thread thread, java.lang.String addr, java.lang.String cluster_name)`
`void` `setAddress(java.lang.String address)`
`void` `setClusterName(java.lang.String channelName)`
`void` `setIncludeClusterName(boolean includeClusterName)`
`void` `setPattern(java.lang.String pattern)`
`void` `setThreadDecorator(ThreadDecorator threadDecorator)` Sets the ThreadDecorator associated this manager should use.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### group

    protected final java.lang.ThreadGroup group

#### baseName

    protected final java.lang.String baseName

#### createDaemons

    protected final boolean createDaemons

#### counter

    protected short counter

#### use_numbering

    protected final boolean use_numbering

#### includeClusterName

    protected boolean includeClusterName

#### includeLocalAddress

    protected boolean includeLocalAddress

#### clusterName

    protected java.lang.String clusterName

#### address

    protected java.lang.String address

#### threadDecorator

    protected ThreadDecorator threadDecorator

### Constructor Detail

#### DefaultThreadFactory

    public DefaultThreadFactory(java.lang.ThreadGroup group,
                        java.lang.String baseName,
                        boolean createDaemons)

#### DefaultThreadFactory

    public DefaultThreadFactory(java.lang.ThreadGroup group,
                        java.lang.String baseName,
                        boolean createDaemons,
                        boolean use_numbering)

### Method Detail

#### setPattern

    public void setPattern(java.lang.String pattern)

#### setIncludeClusterName

    public void setIncludeClusterName(boolean includeClusterName)

#### setClusterName

    public void setClusterName(java.lang.String channelName)

#### setAddress

    public void setAddress(java.lang.String address)

#### getThreadDecorator

    public ThreadDecorator getThreadDecorator()

Description copied from interface: `ThreadManager`
Gets the ThreadDecorator associated with this manager.

Specified by:
  `getThreadDecorator` in interface `ThreadManager`
Returns:
  the ThreadDecorator, or `null` if there is none.

#### setThreadDecorator

    public void setThreadDecorator(ThreadDecorator threadDecorator)

Description copied from interface: `ThreadManager`
Sets the ThreadDecorator associated this manager should use.

Specified by:
  `setThreadDecorator` in interface `ThreadManager`
Parameters:
  `threadDecorator` - the ThreadDecorator, or `null`.

#### newThread

    public java.lang.Thread newThread(java.lang.Runnable r,
                             java.lang.String name)

#### newThread

    public java.lang.Thread newThread(java.lang.Runnable r)

Specified by:
  `newThread` in interface `java.util.concurrent.ThreadFactory`

#### newThread

    public java.lang.Thread newThread(java.lang.ThreadGroup group,
                             java.lang.Runnable r,
                             java.lang.String name)

#### newThread

    protected java.lang.Thread newThread(java.lang.ThreadGroup group,
                             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)

#### renameThread

    public void renameThread(java.lang.String base_name,
                    java.lang.Thread thread,
                    java.lang.String addr,
                    java.lang.String cluster_name)

#### renameThread

    protected void renameThread(java.lang.Thread thread,
                    java.lang.String addr,
                    java.lang.String cluster_name)

#### renameThread

    public void renameThread(java.lang.Thread thread)