|
| |
The Executors class provides factory and
utility methods for Executor, ExecutorService,
ScheduledExecutorService, ThreadFactory,
and Callable classes
Each of the thread pool factory methods returns a thread pool with particular
characteristics:
static ExecutorService |
newCachedThreadPool()
Creates a
thread pool that creates new threads as needed, but will reuse previously
constructed threads when they are available. |
static ExecutorService |
newCachedThreadPool(ThreadFactory threadFactory)
Creates a
thread pool that creates new threads as needed, but will reuse previously
constructed threads when they are available, and uses the provided
ThreadFactory to create new threads when needed. |
static ExecutorService |
newFixedThreadPool(int nThreads)
Creates a
thread pool that reuses a fixed number of threads operating off a shared
unbounded queue. |
static ExecutorService |
newFixedThreadPool(int nThreads, ThreadFactory threadFactory)
Creates a
thread pool that reuses a fixed number of threads operating off a shared
unbounded queue, using the provided ThreadFactory to create new threads
when needed. |
static ScheduledExecutorService |
newScheduledThreadPool(int corePoolSize)
Creates a
thread pool that can schedule commands to run after a given delay, or to
execute periodically. |
static ScheduledExecutorService |
newScheduledThreadPool(int corePoolSize, ThreadFactory threadFactory)
Creates a
thread pool that can schedule commands to run after a given delay, or to
execute periodically. |
static ExecutorService |
newSingleThreadExecutor()
Creates an
Executor that uses a single worker thread operating off an unbounded
queue. |
static ExecutorService |
newSingleThreadExecutor(ThreadFactory threadFactory)
Creates an
Executor that uses a single worker thread operating off an unbounded
queue, and uses the provided ThreadFactory to create a new thread when
needed. |
static ScheduledExecutorService |
newSingleThreadScheduledExecutor()
Creates a
single-threaded executor that can schedule commands to run after a given
delay, or to execute periodically. |
static ScheduledExecutorService |
newSingleThreadScheduledExecutor(ThreadFactory threadFactory)
Creates a
single-threaded executor that can schedule commands to run after a given
delay, or to execute periodically. |
|