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

Comparing jsr166/src/test/tck/AtomicIntegerFieldUpdaterTest.java (file contents):
Revision 1.10 by jsr166, Mon Nov 2 20:28:31 2009 UTC vs.
Revision 1.13 by jsr166, Tue Nov 17 03:12:51 2009 UTC

# Line 14 | Line 14 | public class AtomicIntegerFieldUpdaterTe
14      volatile int x = 0;
15      int w;
16      long z;
17 <    public static void main(String[] args){
17 >    public static void main(String[] args) {
18          junit.textui.TestRunner.run(suite());
19      }
20      public static Test suite() {
# Line 25 | Line 25 | public class AtomicIntegerFieldUpdaterTe
25       * Construction with non-existent field throws RuntimeException
26       */
27      public void testConstructor() {
28 <        try{
28 >        try {
29              AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>
30                  a = AtomicIntegerFieldUpdater.newUpdater
31                  (AtomicIntegerFieldUpdaterTest.class, "y");
# Line 38 | Line 38 | public class AtomicIntegerFieldUpdaterTe
38       * construction with field not of given type throws RuntimeException
39       */
40      public void testConstructor2() {
41 <        try{
41 >        try {
42              AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>
43                  a = AtomicIntegerFieldUpdater.newUpdater
44                  (AtomicIntegerFieldUpdaterTest.class, "z");
# Line 51 | Line 51 | public class AtomicIntegerFieldUpdaterTe
51       * construction with non-volatile field throws RuntimeException
52       */
53      public void testConstructor3() {
54 <        try{
54 >        try {
55              AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>
56                  a = AtomicIntegerFieldUpdater.newUpdater
57                  (AtomicIntegerFieldUpdaterTest.class, "w");
# Line 123 | Line 123 | public class AtomicIntegerFieldUpdaterTe
123       * compareAndSet in one thread enables another waiting for value
124       * to succeed
125       */
126 <    public void testCompareAndSetInMultipleThreads() {
126 >    public void testCompareAndSetInMultipleThreads() throws Exception {
127          x = 1;
128          final AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>a;
129          try {
# Line 134 | Line 134 | public class AtomicIntegerFieldUpdaterTe
134  
135          Thread t = new Thread(new Runnable() {
136                  public void run() {
137 <                    while(!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield();
137 >                    while (!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield();
138                  }});
139 <        try {
140 <            t.start();
141 <            assertTrue(a.compareAndSet(this, 1, 2));
142 <            t.join(LONG_DELAY_MS);
143 <            assertFalse(t.isAlive());
144 <            assertEquals(a.get(this), 3);
145 <        }
146 <        catch(Exception e) {
147 <            unexpectedException();
148 <        }
139 >
140 >        t.start();
141 >        assertTrue(a.compareAndSet(this, 1, 2));
142 >        t.join(LONG_DELAY_MS);
143 >        assertFalse(t.isAlive());
144 >        assertEquals(a.get(this), 3);
145      }
146  
147      /**
# Line 160 | Line 156 | public class AtomicIntegerFieldUpdaterTe
156              return;
157          }
158          x = 1;
159 <        while(!a.weakCompareAndSet(this,1,2));
160 <        while(!a.weakCompareAndSet(this,2,-4));
159 >        while (!a.weakCompareAndSet(this,1,2));
160 >        while (!a.weakCompareAndSet(this,2,-4));
161          assertEquals(-4,a.get(this));
162 <        while(!a.weakCompareAndSet(this,-4,7));
162 >        while (!a.weakCompareAndSet(this,-4,7));
163          assertEquals(7,a.get(this));
164      }
165  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines