[cvs] / jsr166 / src / test / tck / AtomicIntegerFieldUpdaterTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/AtomicIntegerFieldUpdaterTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12, Mon Nov 16 05:30:07 2009 UTC revision 1.13, Tue Nov 17 03:12:51 2009 UTC
# Line 123  Line 123 
123       * compareAndSet in one thread enables another waiting for value       * compareAndSet in one thread enables another waiting for value
124       * to succeed       * to succeed
125       */       */
126      public void testCompareAndSetInMultipleThreads() {      public void testCompareAndSetInMultipleThreads() throws Exception {
127          x = 1;          x = 1;
128          final AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>a;          final AtomicIntegerFieldUpdater<AtomicIntegerFieldUpdaterTest>a;
129          try {          try {
# Line 136  Line 136 
136                  public void run() {                  public void run() {
137                      while (!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield();                      while (!a.compareAndSet(AtomicIntegerFieldUpdaterTest.this, 2, 3)) Thread.yield();
138                  }});                  }});
139          try {  
140              t.start();              t.start();
141              assertTrue(a.compareAndSet(this, 1, 2));              assertTrue(a.compareAndSet(this, 1, 2));
142              t.join(LONG_DELAY_MS);              t.join(LONG_DELAY_MS);
143              assertFalse(t.isAlive());              assertFalse(t.isAlive());
144              assertEquals(a.get(this), 3);              assertEquals(a.get(this), 3);
145          }          }
         catch (Exception e) {  
             unexpectedException();  
         }  
     }  
146    
147      /**      /**
148       * repeated weakCompareAndSet succeeds in changing value when equal       * repeated weakCompareAndSet succeeds in changing value when equal

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8