public class BlockingQueue extends Object implements IBlockingQueue
IBlockingQueue.ClosedException
Constructor and Description |
---|
BlockingQueue()
Create a blocking queue.
|
Modifier and Type | Method and Description |
---|---|
Object |
dequeue()
Dequeue an element.
|
Object |
dequeue(long timeout)
Dequeue an element.
|
void |
enqueue(Object element)
Enqueue an element.
|
boolean |
isClosed()
Check if the queue is closed.
|
static void |
main(String[] args)
Main for testing.
|
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(Object element)
enqueue
in interface IBlockingQueue
element
- The element.public Object dequeue(long timeout) throws IBlockingQueue.ClosedException, TimeoutException
dequeue
in interface IBlockingQueue
timeout
- the time to wait (in millis) or -1 for no timeout.IBlockingQueue.ClosedException
TimeoutException
public Object dequeue() throws IBlockingQueue.ClosedException
dequeue
in interface IBlockingQueue
IBlockingQueue.ClosedException
public boolean isClosed()
isClosed
in interface IBlockingQueue
public List setClosed(boolean closed)
setClosed
in interface IBlockingQueue
closed
- The closed state.public int size()
size
in interface IBlockingQueue
public static void main(String[] args) throws InterruptedException
InterruptedException
public static void test1(String[] args) throws InterruptedException
InterruptedException
public static void test1b(String[] args) throws InterruptedException
InterruptedException
public static void test2(String[] args) throws InterruptedException
InterruptedException
Copyright © 2012. All Rights Reserved.