public class SafeExecutors extends Object
Factory that partially wraps the standard Java Executors concurrency to allow any runtime exceptions to be passed to the ExceptionHandler.
Constructor and Description |
---|
SafeExecutors() |
Modifier and Type | Method and Description |
---|---|
static com.google.common.util.concurrent.ListeningExecutorService |
newFixedThreadPool(int nThreads,
String poolName)
Creates a thread pool that reuses a fixed number of threads
operating off a shared unbounded queue.
|
static com.google.common.util.concurrent.ListeningScheduledExecutorService |
newScheduledThreadPool(int corePoolSize,
String poolName)
Creates a thread pool that can schedule commands to run after a
given delay, or to execute periodically.
|
static com.google.common.util.concurrent.ListeningExecutorService |
newSingleThreadExecutor(String name)
Creates an Executor that uses a single worker thread operating
off an unbounded queue.
|
static com.google.common.util.concurrent.ListeningScheduledExecutorService |
newSingleThreadScheduledExecutor(String name)
Creates a single-threaded executor that can schedule commands
to run after a given delay, or to execute periodically.
|
public static com.google.common.util.concurrent.ListeningExecutorService newSingleThreadExecutor(String name)
public static com.google.common.util.concurrent.ListeningExecutorService newFixedThreadPool(int nThreads, String poolName)
shutdown
.nThreads
- The number of threads in the poolpoolName
- The name of the pool (use lowercase hyphenated)IllegalArgumentException
- if nThreads <= 0
public static com.google.common.util.concurrent.ListeningScheduledExecutorService newSingleThreadScheduledExecutor(String name)
name
- The name of the threadpublic static com.google.common.util.concurrent.ListeningScheduledExecutorService newScheduledThreadPool(int corePoolSize, String poolName)
corePoolSize
- The number of threads to keep in the pool, even if they are idle.poolName
- The name of the pool (use lowercase hyphenated)IllegalArgumentException
- if corePoolSize < 0
Copyright © 2015–2017. All rights reserved.