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, toString
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor
public 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 ExecutorService
submit
in class AbstractExecutorService
public <T> Future<T> submit(Runnable task, T result)
submit
in interface ExecutorService
submit
in class AbstractExecutorService
public void execute(Runnable command)
execute
in interface Executor
execute
in class ThreadPoolExecutor
public <T> Future<T> submit(Callable<T> task)
submit
in interface ExecutorService
submit
in class AbstractExecutorService
protected void beforeExecute(Thread t, Runnable r)
beforeExecute
in class ThreadPoolExecutor
protected void afterExecute(Runnable r, Throwable t)
afterExecute
in class ThreadPoolExecutor