| Method from java.util.concurrent.SynchronousQueue Detail: |
public void clear() {
}
Does nothing.
A SynchronousQueue has no internal capacity. |
public boolean contains(Object o) {
return false;
}
Always returns false.
A SynchronousQueue has no internal capacity. |
public boolean containsAll(Collection c) {
return c.isEmpty();
}
Returns false unless the given collection is empty.
A SynchronousQueue has no internal capacity. |
public int drainTo(Collection c) {
if (c == null)
throw new NullPointerException();
if (c == this)
throw new IllegalArgumentException();
int n = 0;
E e;
while ( (e = poll()) != null) {
c.add(e);
++n;
}
return n;
}
|
public int drainTo(Collection c,
int maxElements) {
if (c == null)
throw new NullPointerException();
if (c == this)
throw new IllegalArgumentException();
int n = 0;
E e;
while (n < maxElements && (e = poll()) != null) {
c.add(e);
++n;
}
return n;
}
|
public boolean isEmpty() {
return true;
}
Always returns true.
A SynchronousQueue has no internal capacity. |
public Iterator iterator() {
return Collections.emptyIterator();
}
Returns an empty iterator in which hasNext always returns
false. |
public boolean offer(E e) {
if (e == null) throw new NullPointerException();
return transferer.transfer(e, true, 0) != null;
}
Inserts the specified element into this queue, if another thread is
waiting to receive it. |
public boolean offer(E o,
long timeout,
TimeUnit unit) throws InterruptedException {
if (o == null) throw new NullPointerException();
if (transferer.transfer(o, true, unit.toNanos(timeout)) != null)
return true;
if (!Thread.interrupted())
return false;
throw new InterruptedException();
}
Inserts the specified element into this queue, waiting if necessary
up to the specified wait time for another thread to receive it. |
public E peek() {
return null;
}
Always returns null.
A SynchronousQueue does not return elements
unless actively waited on. |
public E poll() {
return (E)transferer.transfer(null, true, 0);
}
Retrieves and removes the head of this queue, if another thread
is currently making an element available. |
public E poll(long timeout,
TimeUnit unit) throws InterruptedException {
Object e = transferer.transfer(null, true, unit.toNanos(timeout));
if (e != null || !Thread.interrupted())
return (E)e;
throw new InterruptedException();
}
Retrieves and removes the head of this queue, waiting
if necessary up to the specified wait time, for another thread
to insert it. |
public void put(E o) throws InterruptedException {
if (o == null) throw new NullPointerException();
if (transferer.transfer(o, false, 0) == null) {
Thread.interrupted();
throw new InterruptedException();
}
}
Adds the specified element to this queue, waiting if necessary for
another thread to receive it. |
public int remainingCapacity() {
return 0;
}
Always returns zero.
A SynchronousQueue has no internal capacity. |
public boolean remove(Object o) {
return false;
}
Always returns false.
A SynchronousQueue has no internal capacity. |
public boolean removeAll(Collection c) {
return false;
}
Always returns false.
A SynchronousQueue has no internal capacity. |
public boolean retainAll(Collection c) {
return false;
}
Always returns false.
A SynchronousQueue has no internal capacity. |
public int size() {
return 0;
}
Always returns zero.
A SynchronousQueue has no internal capacity. |
public E take() throws InterruptedException {
Object e = transferer.transfer(null, false, 0);
if (e != null)
return (E)e;
Thread.interrupted();
throw new InterruptedException();
}
Retrieves and removes the head of this queue, waiting if necessary
for another thread to insert it. |
public Object[] toArray() {
return new Object[0];
}
Returns a zero-length array. |
public T[] toArray(T[] a) {
if (a.length > 0)
a[0] = null;
return a;
}
Sets the zeroeth element of the specified array to null
(if the array has non-zero length) and returns it. |