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)
DwAsyncPool
submit
in interface DwAsyncPool
ExecutorService.submit(Callable)
public java.util.concurrent.Future<?> submit(java.lang.Runnable task)
DwAsyncPool
submit
in interface DwAsyncPool
ExecutorService.submit(Runnable)
public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable task, T result)
DwAsyncPool
submit
in interface DwAsyncPool
ExecutorService.submit(Runnable, Object)
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
DwAsyncPool
awaitTermination
in interface DwAsyncPool
java.lang.InterruptedException
ExecutorService.awaitTermination(long, TimeUnit)
public java.util.concurrent.ExecutorService getExecutorService()
ExecutorService
object.public int getActiveCount()
DwAsyncPool
getActiveCount
in interface DwAsyncPool
ThreadPoolExecutor.getActiveCount()
public int getPoolSize()
DwAsyncPool
getPoolSize
in interface DwAsyncPool
ThreadPoolExecutor.getPoolSize()
public int getCorePoolSize()
DwAsyncPool
getCorePoolSize
in interface DwAsyncPool
ThreadPoolExecutor.getCorePoolSize()
public long getTaskCount()
DwAsyncPool
getTaskCount
in interface DwAsyncPool
ThreadPoolExecutor.getTaskCount()
public long getCompletedTaskCount()
DwAsyncPool
getCompletedTaskCount
in interface DwAsyncPool
ThreadPoolExecutor.getCompletedTaskCount()
public boolean isShutdown()
DwAsyncPool
isShutdown
in interface DwAsyncPool
public boolean isTerminated()
DwAsyncPool
isTerminated
in interface DwAsyncPool
public void shutdown()
DwAsyncPool
This method does not wait for previously submitted tasks to complete
execution. Use awaitTermination
to do that.
shutdown
in interface DwAsyncPool
ExecutorService.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 DwAsyncPool
ExecutorService.shutdownNow()