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