public class BlockingQueue<T> extends Object implements IBlockingQueue<T>
IBlockingQueue.ClosedException| Constructor and Description |
|---|
BlockingQueue()
Create a blocking queue.
|
| Modifier and Type | Method and Description |
|---|---|
T |
dequeue()
Dequeue an element.
|
T |
dequeue(long timeout)
Dequeue an element.
|
void |
enqueue(T element)
Enqueue an element.
|
boolean |
isClosed()
Check if the queue is closed.
|
static void |
main(String[] args)
Main for testing.
|
T |
peek()
Peek the topmost element without dequeuing it.
|
List |
setClosed(boolean closed)
Open/close the queue.
|
int |
size()
Return the size of the queue.
|
static void |
test1(String[] args)
Main for testing.
|
static void |
test1b(String[] args)
Main for testing.
|
static void |
test2(String[] args)
Main for testing.
|
public void enqueue(T element)
enqueue in interface IBlockingQueue<T>element - 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.ClosedExceptionTimeoutExceptionpublic T peek() throws IBlockingQueue.ClosedException
peek in interface IBlockingQueue<T>IBlockingQueue.ClosedExceptionpublic T dequeue() throws IBlockingQueue.ClosedException
dequeue in interface IBlockingQueue<T>IBlockingQueue.ClosedExceptionpublic boolean isClosed()
isClosed in interface IBlockingQueue<T>public List setClosed(boolean closed)
setClosed in interface IBlockingQueue<T>closed - The closed state.public int size()
size in interface IBlockingQueue<T>public static void main(String[] args) throws InterruptedException
InterruptedExceptionpublic static void test1(String[] args) throws InterruptedException
InterruptedExceptionpublic static void test1b(String[] args) throws InterruptedException
InterruptedExceptionpublic static void test2(String[] args) throws InterruptedException
InterruptedExceptionCopyright © 2015. All Rights Reserved.