public class BoundedTaskQueue extends AbstractBlockingTaskQueue
BoundedTaskQueue
is an unordered, bounded implementation of a AbstractBlockingTaskQueue
.
This implementation is ThreadSafe
, as it can safely handle multiple consumer
and producer threads writing and/or reading from it.queue
Constructor and Description |
---|
BoundedTaskQueue(int capacity) |
Modifier and Type | Method and Description |
---|---|
void |
enqueue(Task<? extends Object> task)
Adds an element to the head of the queue.
|
int |
getCapacity() |
dequeue
public void enqueue(Task<? extends Object> task) throws InterruptedException
TaskQueue
Thread
is blocked until capacity in the queue has been released.task
- - The Task
which is being added to the queue.InterruptedException
- - The method hands off the responsibility of exception handling to the caller in
event of an interruption in the Thread
.public int getCapacity()
AbstractBlockingTaskQueue
.Copyright © 2020. All rights reserved.