Class NamedThreadFactory
java.lang.Object
com.linkedin.alpini.base.concurrency.NamedThreadFactory
- All Implemented Interfaces:
ThreadFactory
ThreadFactory which creates named threads for use in an ExecutorService. Each factory has a pool name
and threads in the pool will have the name "poolName-X-thread-Y". If multiple factories are created with the same
poolName then each will get its own unique number "X". For example, if two pools were created with the name
"workers" then you would see threads like "workers-1-thread-1" and "workers-2-thread-1".
-
Constructor Summary
ConstructorDescriptionNamedThreadFactory
(String poolName) Construct a new NamedThreadFactory with the given pool name.NamedThreadFactory
(ThreadGroup threadGroup, String poolName) Construct a new NamedThreadFactory with the given thread group and pool name.NamedThreadFactory
(ThreadFactory threadFactory, String poolName) -
Method Summary
-
Constructor Details
-
NamedThreadFactory
Construct a new NamedThreadFactory with the given pool name.- Parameters:
poolName
- the name to be used as part of the prefix for this factory.
-
NamedThreadFactory
Construct a new NamedThreadFactory with the given thread group and pool name.- Parameters:
threadGroup
- the thread group which the new threads belong.poolName
- the name to be used as part of the prefix for this factory.
-
NamedThreadFactory
-
-
Method Details
-
newThread
Create a new Thread for the specifiedRunnable
.- Specified by:
newThread
in interfaceThreadFactory
- Parameters:
runnable
- theRunnable
to be executed by the new thread.- Returns:
- a new
Thread
instance
-
init
-