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

Comparing jsr166/src/test/tck/AtomicReferenceFieldUpdaterTest.java (file contents):
Revision 1.13 by jsr166, Mon Nov 16 05:30:07 2009 UTC vs.
Revision 1.15 by jsr166, Tue Nov 17 06:58:50 2009 UTC

# Line 122 | Line 122 | public class AtomicReferenceFieldUpdater
122       * compareAndSet in one thread enables another waiting for value
123       * to succeed
124       */
125 <    public void testCompareAndSetInMultipleThreads() {
125 >    public void testCompareAndSetInMultipleThreads() throws Exception {
126          x = one;
127          final AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a;
128          try {
# Line 131 | Line 131 | public class AtomicReferenceFieldUpdater
131              return;
132          }
133  
134 <        Thread t = new Thread(new Runnable() {
135 <                public void run() {
136 <                    while (!a.compareAndSet(AtomicReferenceFieldUpdaterTest.this, two, three)) Thread.yield();
137 <                }});
138 <        try {
139 <            t.start();
140 <            assertTrue(a.compareAndSet(this, one, two));
141 <            t.join(LONG_DELAY_MS);
142 <            assertFalse(t.isAlive());
143 <            assertEquals(a.get(this), three);
144 <        }
145 <        catch (Exception e) {
146 <            unexpectedException();
147 <        }
134 >        Thread t = new Thread(new CheckedRunnable() {
135 >            public void realRun() {
136 >                while (!a.compareAndSet(AtomicReferenceFieldUpdaterTest.this, two, three))
137 >                    Thread.yield();
138 >            }});
139 >
140 >        t.start();
141 >        assertTrue(a.compareAndSet(this, one, two));
142 >        t.join(LONG_DELAY_MS);
143 >        assertFalse(t.isAlive());
144 >        assertEquals(a.get(this), three);
145      }
146  
147      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines