ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/CyclicBarrier.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/CyclicBarrier.java (file contents):
Revision 1.35 by jsr166, Wed Sep 14 21:45:12 2005 UTC vs.
Revision 1.36 by jsr166, Tue Jan 10 21:30:33 2006 UTC

# Line 114 | Line 114 | public class CyclicBarrier {
114       */
115      private static class Generation {
116          boolean broken = false;
117        boolean tripped = false;
117      }
118  
119      /** The lock for guarding barrier entry */
# Line 141 | Line 140 | public class CyclicBarrier {
140       */
141      private void nextGeneration() {
142          // signal completion of last generation
144        generation.tripped = true;
143          trip.signalAll();
144          // set up next generation
145          count = parties;
# Line 201 | Line 199 | public class CyclicBarrier {
199                      else if (nanos > 0L)
200                          nanos = trip.awaitNanos(nanos);
201                  } catch (InterruptedException ie) {
202 <                    breakBarrier();
203 <                    throw ie;
202 >                    if (g == generation && ! g.broken) {
203 >                        breakBarrier();
204 >                        throw ie;
205 >                    } else {
206 >                        // We're about to finish waiting even if we had not
207 >                        // been interrupted, so this interrupt is deemed to
208 >                        // "belong" to subsequent execution.
209 >                        Thread.currentThread().interrupt();
210 >                    }
211                  }
212  
213                  if (g.broken)
214                      throw new BrokenBarrierException();
215  
216 <                if (g.tripped)
216 >                if (g != generation)
217                      return index;
218  
219                  if (timed && nanos <= 0L) {
# Line 269 | Line 274 | public class CyclicBarrier {
274       *
275       * <p>If the current thread is not the last to arrive then it is
276       * disabled for thread scheduling purposes and lies dormant until
277 <     * one of following things happens:
277 >     * one of the following things happens:
278       * <ul>
279       * <li>The last thread arrives; or
280       * <li>Some other thread {@link Thread#interrupt interrupts} the current

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines