public class DwAsyncPoolImpl extends java.lang.Object implements DwAsyncPool
DwAsyncPool| Constructor and Description |
|---|
DwAsyncPoolImpl(DwThreadPoolExecutor executorService)
Creates a new thread pool from the given executor.
|
DwAsyncPoolImpl(java.lang.String threadLabel)
Creates a new pool with the given label.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
Blocks until all tasks have completed execution after a shutdown request, or
the timeout occurs, or the current thread is interrupted, whichever happens
first.
|
int |
getActiveCount()
Returns the approximate number of threads that are actively executing tasks.
|
long |
getCompletedTaskCount()
Returns the approximate total number of tasks that have completed execution.
|
int |
getCorePoolSize()
Returns the core number of threads.
|
java.util.concurrent.ExecutorService |
getExecutorService()
Returns the underlying
ExecutorService object. |
int |
getPoolSize()
Returns the current number of threads in the pool.
|
long |
getTaskCount()
Returns the approximate total number of tasks that have ever been scheduled
for execution.
|
boolean |
isShutdown()
Returns true if the pool has been shut down (orderly).
|
boolean |
isTerminated()
Returns true if the pool has been terminated
|
void |
shutdown()
Initiates an orderly shutdown in which previously submitted tasks are
executed, but no new tasks will be accepted.
|
java.util.List<java.lang.Runnable> |
shutdownNow()
Attempts to stop all actively executing tasks, halts the processing of
waiting tasks, and returns a list of the tasks that were awaiting execution.
|
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task)
Submits a value-returning task for execution and returns a Future
representing the pending results of the task.
|
java.util.concurrent.Future<?> |
submit(java.lang.Runnable task)
Submits a Runnable task for execution and returns a Future representing that
task.
|
<T> java.util.concurrent.Future<T> |
submit(java.lang.Runnable task,
T result)
Submits a Runnable task for execution and returns a Future representing that
task.
|
public DwAsyncPoolImpl(java.lang.String threadLabel)
ThreadPoolFactory.newCachedThreadPool(String).threadLabel - ThreadPoolFactory.newCachedThreadPool(String)public DwAsyncPoolImpl(DwThreadPoolExecutor executorService)
executorService - public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
DwAsyncPoolsubmit in interface DwAsyncPoolExecutorService.submit(Callable)public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
DwAsyncPoolsubmit in interface DwAsyncPoolExecutorService.submit(Runnable)public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task,
T result)
DwAsyncPoolsubmit in interface DwAsyncPoolExecutorService.submit(Runnable, Object)public boolean awaitTermination(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException
DwAsyncPoolawaitTermination in interface DwAsyncPooljava.lang.InterruptedExceptionExecutorService.awaitTermination(long, TimeUnit)public java.util.concurrent.ExecutorService getExecutorService()
ExecutorService object.public int getActiveCount()
DwAsyncPoolgetActiveCount in interface DwAsyncPoolThreadPoolExecutor.getActiveCount()public int getPoolSize()
DwAsyncPoolgetPoolSize in interface DwAsyncPoolThreadPoolExecutor.getPoolSize()public int getCorePoolSize()
DwAsyncPoolgetCorePoolSize in interface DwAsyncPoolThreadPoolExecutor.getCorePoolSize()public long getTaskCount()
DwAsyncPoolgetTaskCount in interface DwAsyncPoolThreadPoolExecutor.getTaskCount()public long getCompletedTaskCount()
DwAsyncPoolgetCompletedTaskCount in interface DwAsyncPoolThreadPoolExecutor.getCompletedTaskCount()public boolean isShutdown()
DwAsyncPoolisShutdown in interface DwAsyncPoolpublic boolean isTerminated()
DwAsyncPoolisTerminated in interface DwAsyncPoolpublic void shutdown()
DwAsyncPool
This method does not wait for previously submitted tasks to complete
execution. Use awaitTermination to do that.
shutdown in interface DwAsyncPoolExecutorService.shutdown()public java.util.List<java.lang.Runnable> shutdownNow()
DwAsyncPool
This method does not wait for actively executing tasks to terminate. Use
awaitTermination to do that.
There are no guarantees beyond best-effort attempts to stop processing
actively executing tasks. For example, typical implementations will cancel
via Thread.interrupt(), so any task that fails to respond to interrupts
may never terminate.
shutdownNow in interface DwAsyncPoolExecutorService.shutdownNow()