Package uk.ac.ebi.utils.threading
Class ThreadUtils
java.lang.Object
uk.ac.ebi.utils.threading.ThreadUtils
- Author:
- brandizi
- Date:
- 9 Mar 2020
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThreadFactory
createNamingThreadFactory
(Class<?> namingClass) Uses a default base factory.static ThreadFactory
createNamingThreadFactory
(Class<?> namingClass, ThreadFactory baseFactory) UsesClass.getSimpleName()
as prefix.static ThreadFactory
createNamingThreadFactory
(String prefix) Uses a default base factory.static ThreadFactory
createNamingThreadFactory
(String prefix, ThreadFactory baseFactory) static void
setNamingThreadFactory
(Class<?> namingClass, ExecutorService executor) Works likesetNamingThreadFactory(String, ExecutorService)
, but invokessetNamingThreadFactory(Class, ThreadPoolExecutor)
instead.static void
setNamingThreadFactory
(Class<?> namingClass, ThreadPoolExecutor executor) static void
setNamingThreadFactory
(String prefix, ExecutorService executor) WrapssetNamingThreadFactory(String, ThreadPoolExecutor)
if executor is an instance ofThreadPoolExecutor
, else has no effect.static void
setNamingThreadFactory
(String prefix, ThreadPoolExecutor executor) UsescreateNamingThreadFactory(String, ThreadFactory)
to setup a naming thread factory for this executor, which wraps the existing one.
-
Constructor Details
-
ThreadUtils
public ThreadUtils()
-
-
Method Details
-
createNamingThreadFactory
A simple wrapper ofThreadFactoryBuilder
that creates aThreadFactory
naming new threads like `%d`. This is useful for ThreadPoolExecutor.setThreadFactory(ThreadFactory)
-
createNamingThreadFactory
Uses a default base factory. -
createNamingThreadFactory
public static ThreadFactory createNamingThreadFactory(Class<?> namingClass, ThreadFactory baseFactory) UsesClass.getSimpleName()
as prefix. -
createNamingThreadFactory
Uses a default base factory. -
setNamingThreadFactory
UsescreateNamingThreadFactory(String, ThreadFactory)
to setup a naming thread factory for this executor, which wraps the existing one. -
setNamingThreadFactory
WrapssetNamingThreadFactory(String, ThreadPoolExecutor)
if executor is an instance ofThreadPoolExecutor
, else has no effect. -
setNamingThreadFactory
-
setNamingThreadFactory
Works likesetNamingThreadFactory(String, ExecutorService)
, but invokessetNamingThreadFactory(Class, ThreadPoolExecutor)
instead.
-