implement ConcurrentLinkedQueue.clear

This commit is contained in:
Joel Dice 2011-11-07 15:52:42 -07:00
parent bcb62af2a1
commit a2c6cc8882

View File

@ -25,6 +25,11 @@ public class ConcurrentLinkedQueue<T> {
private volatile Node<T> head = new Node(null, null);
private volatile Node<T> tail = head;
public void clear() {
// todo: can we safely make this O(1)?
while (poll() != null) { }
}
public boolean add(T value) {
Node<T> n = new Node(value, null);
while (true) {