public class ArrayBlockingQueue<T> extends Object implements IBlockingQueue<T>
IBlockingQueue.ClosedException
Constructor and Description |
---|
ArrayBlockingQueue()
Create a new blocking queue.
|
Modifier and Type | Method and Description |
---|---|
T |
dequeue()
Remove an object from the queue
(blocks until an element is available).
|
T |
dequeue(long timeout)
Dequeue an element.
|
void |
enqueue(Object o)
Add an element to the end of the queue.
|
boolean |
isClosed()
Check if the queue is closed.
|
T |
peek()
Peek the topmost element without dequeuing it.
|
List<T> |
setClosed(boolean closed)
Open/close the queue.
|
int |
size()
Get the number of elements in the queue.
|
String |
toString()
Create a string representation.
|
public int size()
size
in interface IBlockingQueue<T>
public void enqueue(Object o)
enqueue
in interface IBlockingQueue<T>
o
- The element.public T dequeue(long timeout) throws IBlockingQueue.ClosedException, TimeoutException
dequeue
in interface IBlockingQueue<T>
timeout
- the time to wait (in millis) or -1 for no timeout.IBlockingQueue.ClosedException
TimeoutException
public T peek() throws IBlockingQueue.ClosedException
peek
in interface IBlockingQueue<T>
IBlockingQueue.ClosedException
public T dequeue()
dequeue
in interface IBlockingQueue<T>
public List<T> setClosed(boolean closed)
setClosed
in interface IBlockingQueue<T>
closed
- The closed state.public boolean isClosed()
isClosed
in interface IBlockingQueue<T>
Copyright © 2013. All Rights Reserved.