public final class ThreadPoolUtils
extends java.lang.Object
Constructor and Description |
---|
ThreadPoolUtils() |
Modifier and Type | Method and Description |
---|---|
static java.util.concurrent.ThreadFactory |
createDaemonThreadFactory(java.lang.Class<?> clazz) |
static java.util.concurrent.ThreadFactory |
createDaemonThreadFactory(java.lang.Class<?> clazz,
int instanceId)
poolName will be appended with a hyphen and the threadId. |
static java.util.concurrent.ThreadFactory |
createDaemonThreadFactory(java.lang.Class<?> clazz,
java.lang.String uniqueId)
poolName will be appended with a hyphen and the unique name. |
static java.util.concurrent.ThreadFactory |
createNamedDaemonThreadFactory(java.lang.String poolName) |
static java.util.concurrent.ThreadPoolExecutor |
newLimitedThreadPool(int minNumberOfThreads,
int maxNumberOfThreads,
long defaultRemoveIdleThread,
int bufferSize) |
static void |
stop(java.util.concurrent.ExecutorService executorService,
long timeout,
java.util.concurrent.TimeUnit timeUnit)
This method is used to shutdown ExecutorService
|
public static java.util.concurrent.ThreadPoolExecutor newLimitedThreadPool(int minNumberOfThreads, int maxNumberOfThreads, long defaultRemoveIdleThread, int bufferSize)
public static void stop(java.util.concurrent.ExecutorService executorService, long timeout, java.util.concurrent.TimeUnit timeUnit)
executorService
- The instance of ExecutorService to shutdowntimeout
- Max time to waittimeUnit
- Timeunit for timeoutpublic static java.util.concurrent.ThreadFactory createDaemonThreadFactory(java.lang.Class<?> clazz, int instanceId)
poolName
will be appended with a hyphen and the threadId.clazz
- The class holding the thread poolinstanceId
- The identifier of the instance of clazz
public static java.util.concurrent.ThreadFactory createDaemonThreadFactory(java.lang.Class<?> clazz, java.lang.String uniqueId)
poolName
will be appended with a hyphen and the unique name.clazz
- The class holding the thread pooluniqueId
- The identifier of the instance of clazz
public static java.util.concurrent.ThreadFactory createDaemonThreadFactory(java.lang.Class<?> clazz)
public static java.util.concurrent.ThreadFactory createNamedDaemonThreadFactory(java.lang.String poolName)