samples/reentrant/src/org/apidesign/reentrant/CriticalSectionReentrantImmutable.java
changeset 210 acf2c31e22d4
parent 209 1c999569643b
     1.1 --- a/samples/reentrant/src/org/apidesign/reentrant/CriticalSectionReentrantImmutable.java	Sat Jun 14 10:04:51 2008 +0200
     1.2 +++ b/samples/reentrant/src/org/apidesign/reentrant/CriticalSectionReentrantImmutable.java	Sat Jun 14 10:04:53 2008 +0200
     1.3 @@ -13,7 +13,10 @@
     1.4      // BEGIN: reentrant.merge.immutable
     1.5      public int sumBigger(Collection<T> args) {
     1.6          for (;;) {
     1.7 -            ImmutableData<T> previous = this.data;
     1.8 +            ImmutableData<T> previous;
     1.9 +            synchronized (this) {
    1.10 +                previous = this.data;
    1.11 +            }
    1.12              int[] ret = { 0 };
    1.13              ImmutableData<T> now = doCriticalSection(args, previous, ret);
    1.14