samples/reentrant/src/org/apidesign/reentrant/CriticalSectionReentrant.java
changeset 112 64308321f7bd
parent 111 3905a2e66b9b
child 115 2c1b90108e02
     1.1 --- a/samples/reentrant/src/org/apidesign/reentrant/CriticalSectionReentrant.java	Sat Jun 14 09:54:36 2008 +0200
     1.2 +++ b/samples/reentrant/src/org/apidesign/reentrant/CriticalSectionReentrant.java	Sat Jun 14 09:54:37 2008 +0200
     1.3 @@ -13,16 +13,20 @@
     1.4  
     1.5      public int sumBigger(Collection<T> args) {
     1.6          T pilotCopy = this.pilot;
     1.7 +        int own = doCriticalSection(args, pilotCopy);
     1.8 +        // now merge with global state
     1.9 +        cnt.addAndGet(own);
    1.10 +        return own;
    1.11 +    }
    1.12 +    
    1.13 +    private int doCriticalSection(Collection<T> args, T pilotCopy) {
    1.14          int own = 0;
    1.15          for (T cmp : args) {
    1.16              if (pilotCopy.compareTo(cmp) < 0) {
    1.17                  own++;
    1.18              }
    1.19          }
    1.20 -        cnt.addAndGet(own);
    1.21          return own;
    1.22 -        
    1.23 -        
    1.24      }
    1.25  
    1.26      public int getCount() {