public final class BoundedThreadPool extends ThreadPoolExecutor
When a new job would exceed the queue bound, the job is run on the caller's thread rather than on a thread from the pool.
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute(Runnable r,
Throwable t) |
protected void |
beforeExecute(Thread t,
Runnable r) |
void |
execute(Runnable command) |
static BoundedThreadPool |
newFixedThreadPool(int numberOfThreads,
ThreadFactory threadFactory)
Returns a fixed-size, bounded executor service.
|
static BoundedThreadPool |
newSingleThreadExecutor(ThreadFactory threadFactory)
Returns a single-thread, bounded executor service.
|
<T> Future<T> |
submit(Callable<T> task) |
Future<?> |
submit(Runnable task) |
<T> Future<T> |
submit(Runnable task,
T result) |
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toStringinvokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskForpublic static BoundedThreadPool newSingleThreadExecutor(ThreadFactory threadFactory)
threadFactory - thread factory for the worker thread.public static BoundedThreadPool newFixedThreadPool(int numberOfThreads, ThreadFactory threadFactory)
numberOfThreads - number of threads in the poolthreadFactory - thread factory for the worker threads.public Future<?> submit(Runnable task)
submit in interface ExecutorServicesubmit in class AbstractExecutorServicepublic <T> Future<T> submit(Runnable task, T result)
submit in interface ExecutorServicesubmit in class AbstractExecutorServicepublic void execute(Runnable command)
execute in interface Executorexecute in class ThreadPoolExecutorpublic <T> Future<T> submit(Callable<T> task)
submit in interface ExecutorServicesubmit in class AbstractExecutorServiceprotected void beforeExecute(Thread t, Runnable r)
beforeExecute in class ThreadPoolExecutorprotected void afterExecute(Runnable r, Throwable t)
afterExecute in class ThreadPoolExecutor