Object
AbstractExecutorService
BlockingExecutorService
- All Implemented Interfaces:
AutoCloseable
,Executor
,ExecutorService
BlockingExecutorService keeps pool of worker threads which read tasks from the blocking queue.
If blocking queue is bounded then thread submitting a new task to this executor will block until new space in queue became available (with standard ThreadPoolExecutor such task will be rejected).
-
Constructor Summary
ConstructorDescriptionBlockingExecutorService
(int capacity) BlockingExecutorService
(int maximumPoolSize, int capacity) Creates executor with bounded queue of given capacity. -
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long timeout, TimeUnit unit) This call blocks indefinitely if there are some pending tasks in the queue which is yet to be taken.void
boolean
boolean
void
shutdown()
Methods inherited from class AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ExecutorService
close
-
Constructor Details
-
BlockingExecutorService
public BlockingExecutorService(int maximumPoolSize, int capacity) Creates executor with bounded queue of given capacity.- Parameters:
maximumPoolSize
- number of worker threads which will be created and be waiting for a new taskscapacity
- size of the internal queue from which worker will pick up the tasks
-
BlockingExecutorService
public BlockingExecutorService(int capacity)
-
-
Method Details
-
shutdown
public void shutdown() -
shutdownNow
-
isShutdown
public boolean isShutdown() -
isTerminated
public boolean isTerminated() -
awaitTermination
This call blocks indefinitely if there are some pending tasks in the queue which is yet to be taken.If the queue is empty it behaves as
ExecutorService.awaitTermination(long, TimeUnit)
- Throws:
InterruptedException
-
execute
-