Top Description Fields Constructors Methods
org.freedesktop.dbus.utils

public Class NameableThreadFactory

extends Object
implements ThreadFactory
Class Inheritance
All Implemented Interfaces
java.util.concurrent.ThreadFactory
Imports
java.util.concurrent.ThreadFactory, java.util.concurrent.atomic.AtomicInteger

A thread factory which allows setting name, priority and daemon flag for all newly created threads.

Field Summary

Modifier and TypeField and Description
private final boolean
private final ThreadGroup
private final String
private static final AtomicInteger
private final AtomicInteger
private final int

Constructor Summary

AccessConstructor and Description
public
NameableThreadFactory(String
prefix for all thread names
_name
,
boolean
turn all created threads to daemon threads
_daemonizeThreads
)

Create a new ThreadFactory instance.

public
NameableThreadFactory(String
prefix for all thread names
_name
,
boolean
turn all created threads to daemon threads
_daemonizeThreads
,
int
priority to use for new threads
_threadPriority
)

Create a new ThreadFactory instance.

Method Summary

Modifier and TypeMethod and Description
public Thread
newThread(Runnable
a runnable to be executed by new thread instance
_runnable
)

Implements java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

daemonizeThreadsback to summary
private final boolean daemonizeThreads
groupback to summary
private final ThreadGroup group
namePrefixback to summary
private final String namePrefix
POOL_NUMBERback to summary
private static final AtomicInteger POOL_NUMBER
threadNumberback to summary
private final AtomicInteger threadNumber
threadPriorityback to summary
private final int threadPriority

Constructor Detail

NameableThreadFactoryback to summary
public NameableThreadFactory(String _name, boolean _daemonizeThreads)

Create a new ThreadFactory instance. The thread name is created like this: _name + THREAD_NUMBER e.g: connectionPool-1 If _name is null or blank, UnnamedThreadPool-POOL_NUMBER-thread-THREAD_NUMBER will be used.

Parameters
_name:String

prefix for all thread names

_daemonizeThreads:boolean

turn all created threads to daemon threads

NameableThreadFactoryback to summary
public NameableThreadFactory(String _name, boolean _daemonizeThreads, int _threadPriority)

Create a new ThreadFactory instance. The thread name is created like this: _name + THREAD_NUMBER e.g: connectionPool-1 If _name is null or blank, UnnamedThreadPool-POOL_NUMBER-thread-THREAD_NUMBER will be used.

Parameters
_name:String

prefix for all thread names

_daemonizeThreads:boolean

turn all created threads to daemon threads

_threadPriority:int

priority to use for new threads

Since
4.2.0 - 2022-07-13

Method Detail

newThreadback to summary
public Thread newThread(Runnable _runnable)

Implements java.util.concurrent.ThreadFactory.newThread.

Doc from java.util.concurrent.ThreadFactory.newThread.

Constructs a new unstarted Thread to run the given runnable.

Parameters
_runnable:Runnable

a runnable to be executed by new thread instance

Returns:Thread

constructed thread, or null if the request to create a thread is rejected

Annotations
@Override