public class Queue
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected int |
capacity
Field capacity, threshold
|
protected boolean |
closed
Field closed
|
protected java.util.LinkedList<java.lang.Object> |
queue
Field queue
|
protected int |
threshold
Field capacity, threshold
|
Constructor and Description |
---|
Queue()
Instantiate a blocking queue with no bounded capacity.
|
Queue(int capacity)
Instantiate a blocking queue with the specified capacity.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the queue and notify all waiting Threads.
|
java.lang.Object |
dequeue()
Blocks until an object is dequeued or the queue is closed.
|
void |
enqueue(java.lang.Object element)
Enqueue an object and notify all waiting Threads.
|
protected boolean closed
protected java.util.LinkedList<java.lang.Object> queue
protected int capacity
protected int threshold
public Queue()
public Queue(int capacity)
public void enqueue(java.lang.Object element) throws java.lang.InterruptedException
java.lang.InterruptedException
public java.lang.Object dequeue() throws java.lang.InterruptedException
java.lang.InterruptedException
public void close()