org.jgroups.util
Class DefaultThreadFactory

java.lang.Object
  extended by org.jgroups.util.DefaultThreadFactory
All Implemented Interfaces:
java.util.concurrent.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

Field Summary
protected  java.lang.String address
           
protected  java.lang.String baseName
           
protected  java.lang.String clusterName
           
protected  short counter
           
protected  boolean createDaemons
           
protected  boolean includeClusterName
           
protected  boolean includeLocalAddress
           
protected  boolean use_numbering
           
 
Constructor Summary
DefaultThreadFactory(java.lang.String baseName, boolean createDaemons)
           
DefaultThreadFactory(java.lang.String baseName, boolean createDaemons, boolean use_numbering)
           
 
Method Summary
 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)
           
 java.lang.Thread newThread(java.lang.ThreadGroup group, java.lang.Runnable r, java.lang.String 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)
           
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)
           
 
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
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)

setIncludeClusterName

public void setIncludeClusterName(boolean includeClusterName)

setClusterName

public void setClusterName(java.lang.String channelName)

setAddress

public void setAddress(java.lang.String address)

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.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)
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

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

renameThread

public void renameThread(java.lang.Thread thread)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.