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

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

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

revision 1.4, Mon Dec 29 19:05:40 2003 UTC revision 1.5, Tue Dec 30 15:48:38 2003 UTC
# Line 32  Line 32 
32          private static class Sync extends AbstractQueuedSynchronizer {          private static class Sync extends AbstractQueuedSynchronizer {
33              public int acquireExclusiveState(boolean isQueued, int acquires) {              public int acquireExclusiveState(boolean isQueued, int acquires) {
34                  assert acquires == 1; // Does not use multiple acquires                  assert acquires == 1; // Does not use multiple acquires
35                  return state().compareAndSet(0, 1)? 0 : -1;                  return compareAndSet(0, 1)? 0 : -1;
36              }              }
37    
38              public boolean releaseExclusiveState(int releases) {              public boolean releaseExclusiveState(int releases) {
39                  state().set(0);                  set(0);
40                  return true;                  return true;
41              }              }
42    
             public int acquireSharedState(boolean isQueued, int acquires) {  
                 throw new UnsupportedOperationException();  
             }  
   
             public boolean releaseSharedState(int releases) {  
                 throw new UnsupportedOperationException();  
             }  
   
43              public void checkConditionAccess(Thread thread, boolean waiting) {              public void checkConditionAccess(Thread thread, boolean waiting) {
44                  if (state().get() == 0) throw new IllegalMonitorStateException();                  if (get() == 0) throw new IllegalMonitorStateException();
45              }              }
46    
47              Condition newCondition() { return new ConditionObject(); }              Condition newCondition() { return new ConditionObject(); }
48    
49              private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {              private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
50                  s.defaultReadObject();                  s.defaultReadObject();
51                  state().set(0); // reset to unlocked state                  set(0); // reset to unlocked state
52              }              }
53          }          }
54    
# Line 75  Line 67 
67          }          }
68          public void unlock() { sync.releaseExclusive(1); }          public void unlock() { sync.releaseExclusive(1); }
69          public Condition newCondition() { return sync.newCondition(); }          public Condition newCondition() { return sync.newCondition(); }
70          public boolean isLocked() { return sync.state().get() != 0; }          public boolean isLocked() { return sync.get() != 0; }
71          public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); }          public boolean hasQueuedThreads() { return sync.hasQueuedThreads(); }
72      }      }
73    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8