public final class BoundedThreadPool
extends java.util.concurrent.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.
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy| Modifier and Type | Field and Description |
|---|---|
protected static int |
maxQueueSize |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterExecute(java.lang.Runnable r,
java.lang.Throwable t) |
protected void |
beforeExecute(java.lang.Thread t,
java.lang.Runnable r) |
void |
execute(java.lang.Runnable command) |
static BoundedThreadPool |
newFixedThreadPool(int numberOfThreads,
java.util.concurrent.ThreadFactory threadFactory)
Returns a fixed-size, bounded executor service.
|
static BoundedThreadPool |
newSingleThreadExecutor(java.util.concurrent.ThreadFactory threadFactory)
Returns a single-thread, bounded executor service.
|
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task) |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task) |
<T> java.util.concurrent.Future<T> |
submit(java.lang.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, toStringpublic static BoundedThreadPool newSingleThreadExecutor(java.util.concurrent.ThreadFactory threadFactory)
threadFactory - thread factory for the worker thread.public static BoundedThreadPool newFixedThreadPool(int numberOfThreads, java.util.concurrent.ThreadFactory threadFactory)
numberOfThreads - number of threads in the poolthreadFactory - thread factory for the worker threads.public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
submit in interface java.util.concurrent.ExecutorServicesubmit in class java.util.concurrent.AbstractExecutorServicepublic <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task,
T result)
submit in interface java.util.concurrent.ExecutorServicesubmit in class java.util.concurrent.AbstractExecutorServicepublic void execute(java.lang.Runnable command)
execute in interface java.util.concurrent.Executorexecute in class java.util.concurrent.ThreadPoolExecutorpublic <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
submit in interface java.util.concurrent.ExecutorServicesubmit in class java.util.concurrent.AbstractExecutorServiceprotected void beforeExecute(java.lang.Thread t,
java.lang.Runnable r)
beforeExecute in class java.util.concurrent.ThreadPoolExecutorprotected void afterExecute(java.lang.Runnable r,
java.lang.Throwable t)
afterExecute in class java.util.concurrent.ThreadPoolExecutor