ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/loops/SynchronizedCollection.java
(Generate patch)

Comparing jsr166/src/test/loops/SynchronizedCollection.java (file contents):
Revision 1.1 by dl, Tue Oct 4 20:09:41 2005 UTC vs.
Revision 1.4 by jsr166, Thu Sep 16 03:57:13 2010 UTC

# Line 1 | Line 1
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)
# Line 25 | Line 29 | public final class SynchronizedCollectio
29      }
30  
31      public final int size() {
32 <        synchronized(mutex) {return c.size();}
32 >        synchronized (mutex) {return c.size();}
33      }
34      public final boolean isEmpty() {
35 <        synchronized(mutex) {return c.isEmpty();}
35 >        synchronized (mutex) {return c.isEmpty();}
36      }
37      public final boolean contains(Object o) {
38 <        synchronized(mutex) {return c.contains(o);}
38 >        synchronized (mutex) {return c.contains(o);}
39      }
40      public final Object[] toArray() {
41 <        synchronized(mutex) {return c.toArray();}
41 >        synchronized (mutex) {return c.toArray();}
42      }
43      public final <T> T[] toArray(T[] a) {
44 <        synchronized(mutex) {return c.toArray(a);}
44 >        synchronized (mutex) {return c.toArray(a);}
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) {
52 <        synchronized(mutex) {return c.add(e);}
52 >        synchronized (mutex) {return c.add(e);}
53      }
54      public final boolean remove(Object o) {
55 <        synchronized(mutex) {return c.remove(o);}
55 >        synchronized (mutex) {return c.remove(o);}
56      }
57  
58      public final boolean containsAll(Collection<?> coll) {
59 <        synchronized(mutex) {return c.containsAll(coll);}
59 >        synchronized (mutex) {return c.containsAll(coll);}
60      }
61      public final boolean addAll(Collection<? extends E> coll) {
62 <        synchronized(mutex) {return c.addAll(coll);}
62 >        synchronized (mutex) {return c.addAll(coll);}
63      }
64      public final boolean removeAll(Collection<?> coll) {
65 <        synchronized(mutex) {return c.removeAll(coll);}
65 >        synchronized (mutex) {return c.removeAll(coll);}
66      }
67      public final boolean retainAll(Collection<?> coll) {
68 <        synchronized(mutex) {return c.retainAll(coll);}
68 >        synchronized (mutex) {return c.retainAll(coll);}
69      }
70      public final void clear() {
71 <        synchronized(mutex) {c.clear();}
71 >        synchronized (mutex) {c.clear();}
72      }
73      public final String toString() {
74 <        synchronized(mutex) {return c.toString();}
74 >        synchronized (mutex) {return c.toString();}
75      }
76      private void writeObject(ObjectOutputStream s) throws IOException {
77 <        synchronized(mutex) {s.defaultWriteObject();}
77 >        synchronized (mutex) {s.defaultWriteObject();}
78      }
79   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines