Package org.jgroups.util
Class DefaultThreadFactory
- java.lang.Object
-
- org.jgroups.util.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
-
-
Field Summary
Fields Modifier and Type Field Description 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 Log
log
protected boolean
use_numbering
protected boolean
use_vthreads
-
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>
Tlog(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>
TuseFibers(boolean f)
Deprecated, for removal: This API element is subject to removal in a future version.boolean
useVirtualThreads()
<T extends DefaultThreadFactory>
TuseVirtualThreads(boolean f)
-
-
-
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_vthreads
protected boolean use_vthreads
-
log
protected Log log
-
-
Method Detail
-
setPattern
public void setPattern(java.lang.String pattern)
- Specified by:
setPattern
in interfaceThreadFactory
-
setIncludeClusterName
public void setIncludeClusterName(boolean includeClusterName)
- Specified by:
setIncludeClusterName
in interfaceThreadFactory
-
setClusterName
public void setClusterName(java.lang.String channelName)
- Specified by:
setClusterName
in interfaceThreadFactory
-
setAddress
public void setAddress(java.lang.String address)
- Specified by:
setAddress
in interfaceThreadFactory
-
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()
- Specified by:
useVirtualThreads
in interfaceThreadFactory
-
useVirtualThreads
public <T extends DefaultThreadFactory> T useVirtualThreads(boolean f)
-
log
public <T extends DefaultThreadFactory> T log(Log l)
-
newThread
public java.lang.Thread newThread(java.lang.Runnable r, java.lang.String name)
- Specified by:
newThread
in interfaceThreadFactory
-
newThread
public java.lang.Thread newThread(java.lang.Runnable r)
- Specified by:
newThread
in interfacejava.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 interfaceThreadFactory
-
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)
-
-