1 |
+ |
|
2 |
+ |
/* |
3 |
+ |
* Written by Doug Lea with assistance from members of JCP JSR-166 |
4 |
+ |
* Expert Group and released to the public domain, as explained at |
5 |
+ |
* http://creativecommons.org/licenses/publicdomain |
6 |
+ |
*/ |
7 |
+ |
|
8 |
|
// Stand-alone version of java.util.Collections.synchronizedCollection |
9 |
|
import java.util.*; |
10 |
|
import java.io.*; |
11 |
|
|
12 |
|
public final class SynchronizedCollection<E> implements Collection<E>, Serializable { |
13 |
< |
// use serialVersionUID from JDK 1.2.2 for interoperability |
14 |
< |
private static final long serialVersionUID = 3053995032091335093L; |
8 |
< |
|
9 |
< |
final Collection<E> c; // Backing Collection |
10 |
< |
final Object mutex; // Object on which to synchronize |
13 |
> |
final Collection<E> c; // Backing Collection |
14 |
> |
final Object mutex; // Object on which to synchronize |
15 |
|
|
16 |
|
public SynchronizedCollection(Collection<E> c) { |
17 |
|
if (c==null) |
45 |
|
} |
46 |
|
|
47 |
|
public final Iterator<E> iterator() { |
48 |
< |
return c.iterator(); // Must be manually synched by user! |
48 |
> |
return c.iterator(); |
49 |
|
} |
50 |
|
|
51 |
|
public final boolean add(E e) { |