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

Comparing jsr166/src/main/java/util/concurrent/Semaphore.java (file contents):
Revision 1.58 by jsr166, Wed Jun 8 00:50:35 2011 UTC vs.
Revision 1.59 by jsr166, Thu Jun 9 07:48:43 2011 UTC

# Line 19 | Line 19 | import java.util.concurrent.locks.*;
19   * <p>Semaphores are often used to restrict the number of threads than can
20   * access some (physical or logical) resource. For example, here is
21   * a class that uses a semaphore to control access to a pool of items:
22 < * <pre>
22 > *  <pre> {@code
23   * class Pool {
24   *   private static final int MAX_AVAILABLE = 100;
25   *   private final Semaphore available = new Semaphore(MAX_AVAILABLE, true);
# Line 61 | Line 61 | import java.util.concurrent.locks.*;
61   *     }
62   *     return false;
63   *   }
64 < *
65 < * }
66 < * </pre>
64 > * }}</pre>
65   *
66   * <p>Before obtaining an item each thread must acquire a permit from
67   * the semaphore, guaranteeing that an item is available for use. When

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines