public class Queue<E>
extends java.util.Vector<E>
Queue
class represents a first-in-first-out (FIFO) queue of
objects.构造器和说明 |
---|
Queue(int size)
Constructs an Queue with the specifies maximum size.
|
限定符和类型 | 方法和说明 |
---|---|
void |
close()
Closes the queue, i.e. wakes up all threads blocking on a call to remove().
|
void |
insert(E item)
Inserts an item into the queue.
|
void |
insertFirst(E item)
Inserts an item first into the queue.
|
E |
remove()
Removes and returns the first object in the queue.
|
E |
removeWait(float timeout)
Removes and returns the first item in the queue.
|
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, toString, trimToSize
public Queue(int size)
size
- maximum queue size.public void insert(E item) throws java.lang.IndexOutOfBoundsException
remove
, one of them is unblocked.item
- the item to be inserted.java.lang.IndexOutOfBoundsException
- if maximum queue size is reached.public void insertFirst(E item)
remove
, one of them is unblocked.item
- the item to be inserted.public E removeWait(float timeout)
timeout
- timeout in seconds.null
if a timeout
occurred. To distinguish timeouts, null
items should
not be inserted in the queue.public E remove()
remove(float timeout)
but this function blocks forever.public void close()