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

Comparing jsr166/src/test/tck/AtomicReferenceTest.java (file contents):
Revision 1.11 by jsr166, Mon Nov 16 05:30:07 2009 UTC vs.
Revision 1.12 by jsr166, Tue Nov 17 03:12:51 2009 UTC

# Line 76 | Line 76 | public class AtomicReferenceTest extends
76       * compareAndSet in one thread enables another waiting for value
77       * to succeed
78       */
79 <    public void testCompareAndSetInMultipleThreads() {
79 >    public void testCompareAndSetInMultipleThreads() throws Exception {
80          final AtomicReference ai = new AtomicReference(one);
81          Thread t = new Thread(new Runnable() {
82                  public void run() {
83                      while (!ai.compareAndSet(two, three)) Thread.yield();
84                  }});
85 <        try {
86 <            t.start();
87 <            assertTrue(ai.compareAndSet(one, two));
88 <            t.join(LONG_DELAY_MS);
89 <            assertFalse(t.isAlive());
90 <            assertEquals(ai.get(), three);
91 <        }
92 <        catch (Exception e) {
93 <            unexpectedException();
94 <        }
85 >
86 >        t.start();
87 >        assertTrue(ai.compareAndSet(one, two));
88 >        t.join(LONG_DELAY_MS);
89 >        assertFalse(t.isAlive());
90 >        assertEquals(ai.get(), three);
91      }
92  
93      /**
# Line 120 | Line 116 | public class AtomicReferenceTest extends
116      /**
117       * a deserialized serialized atomic holds same value
118       */
119 <    public void testSerialization() {
119 >    public void testSerialization() throws Exception {
120          AtomicReference l = new AtomicReference();
121  
122 <        try {
123 <            l.set(one);
124 <            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
125 <            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
126 <            out.writeObject(l);
127 <            out.close();
128 <
129 <            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
130 <            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
131 <            AtomicReference r = (AtomicReference) in.readObject();
136 <            assertEquals(l.get(), r.get());
137 <        } catch (Exception e) {
138 <            unexpectedException();
139 <        }
122 >        l.set(one);
123 >        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
124 >        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
125 >        out.writeObject(l);
126 >        out.close();
127 >
128 >        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
129 >        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
130 >        AtomicReference r = (AtomicReference) in.readObject();
131 >        assertEquals(l.get(), r.get());
132      }
133  
134      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines