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

Comparing jsr166/src/main/java/util/concurrent/FairSemaphore.java (file contents):
Revision 1.1 by dl, Tue May 27 15:50:14 2003 UTC vs.
Revision 1.2 by dl, Sat Jun 7 16:07:09 2003 UTC

# Line 7 | Line 7
7   package java.util.concurrent;
8  
9   /**
10 < * A semaphore that guarantees that threads invoking
11 < * any of the {@link #acquire() acquire} methods
12 < * are allocated permits in the order in
13 < * which their invocation of those methods was processed (first-in-first-out).
10 > * A semaphore guaranteeing that threads invoking any of the {@link
11 > * #acquire() acquire} methods are allocated permits in the order in
12 > * which their invocation of those methods was processed
13 > * (first-in-first-out; FIFO). Note that FIFO ordering necessarily
14 > * applies to specific internal points of execution within these
15 > * methods.  So, it is possible for one thread to invoke
16 > * <tt>acquire</tt> before another, but reach the ordering point after
17 > * the other, and similarly upon return from the method.
18   *
19 < * <p>This class introduces a fairness guarantee that can be useful
20 < * in some contexts.
21 < * However, it needs to be realized that the order in which invocations are
18 < * processed can be different from the order in which an application perceives
19 < * those invocations to be processed. Effectively, when no permit is available
20 < * each thread is stored in a FIFO queue. As permits are released, they
21 < * are allocated to the thread at the head of the queue, and so the order
22 < * in which threads enter the queue, is the order in which they come out.  
23 < * This order need not have any relationship to the order in which requests
24 < * were made, nor the order in which requests actually return to the caller as
25 < * these depend on the underlying thread scheduling, which is not guaranteed
26 < * to be predictable or fair.
27 < *
28 < * <p>As permits are allocated in-order, this class also provides convenience
29 < * methods to {@link #acquire(long) acquire} and
30 < * {@link #release(long) release} multiple permits at a time.
19 > * <p>Because permits are allocated in-order, this class also provides
20 > * convenience methods to {@link #acquire(long) acquire} and {@link
21 > * #release(long) release} multiple permits at a time.
22   *
23   * @since 1.5
24   * @spec JSR-166
# Line 298 | Line 289 | public class FairSemaphore extends Semap
289              lock.unlock();
290          }
291      }
301        
302
303
292   }
305
306
307
308
309

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines