1 |
/* |
2 |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
3 |
* Expert Group and released to the public domain, as explained at |
4 |
* http://creativecommons.org/licenses/publicdomain |
5 |
*/ |
6 |
|
7 |
import java.util.*; |
8 |
import java.util.concurrent.*; |
9 |
import java.util.concurrent.locks.*; |
10 |
|
11 |
public class SynchronizedLinkedListQueue<E> |
12 |
extends AbstractCollection<E> implements Queue<E> { |
13 |
private final Queue<E> q = new LinkedList<E>(); |
14 |
|
15 |
public synchronized Iterator<E> iterator() { |
16 |
return q.iterator(); |
17 |
} |
18 |
|
19 |
public synchronized boolean isEmpty() { |
20 |
return q.isEmpty(); |
21 |
} |
22 |
public synchronized int size() { |
23 |
return q.size(); |
24 |
} |
25 |
public synchronized boolean offer(E o) { |
26 |
return q.offer(o); |
27 |
} |
28 |
public synchronized boolean add(E o) { |
29 |
return q.add(o); |
30 |
} |
31 |
public synchronized E poll() { |
32 |
return q.poll(); |
33 |
} |
34 |
public synchronized E remove() { |
35 |
return q.remove(); |
36 |
} |
37 |
public synchronized E peek() { |
38 |
return q.peek(); |
39 |
} |
40 |
public synchronized E element() { |
41 |
return q.element(); |
42 |
} |
43 |
|
44 |
public synchronized boolean contains(Object o) { |
45 |
return q.contains(o); |
46 |
} |
47 |
public synchronized Object[] toArray() { |
48 |
return q.toArray(); |
49 |
} |
50 |
public synchronized <T> T[] toArray(T[] a) { |
51 |
return q.toArray(a); |
52 |
} |
53 |
public synchronized boolean remove(Object o) { |
54 |
return q.remove(o); |
55 |
} |
56 |
|
57 |
public synchronized boolean containsAll(Collection<?> coll) { |
58 |
return q.containsAll(coll); |
59 |
} |
60 |
public synchronized boolean addAll(Collection<? extends E> coll) { |
61 |
return q.addAll(coll); |
62 |
} |
63 |
public synchronized boolean removeAll(Collection<?> coll) { |
64 |
return q.removeAll(coll); |
65 |
} |
66 |
public synchronized boolean retainAll(Collection<?> coll) { |
67 |
return q.retainAll(coll); |
68 |
} |
69 |
public synchronized void clear() { |
70 |
q.clear(); |
71 |
} |
72 |
public synchronized String toString() { |
73 |
return q.toString(); |
74 |
} |
75 |
|
76 |
} |
77 |
|