src/share/classes/java/util/concurrent/Semaphore.java

Print this page

        

*** 221,231 **** } /** * NonFair version */ ! final static class NonfairSync extends Sync { private static final long serialVersionUID = -2694183684443567898L; NonfairSync(int permits) { super(permits); } --- 221,231 ---- } /** * NonFair version */ ! static final class NonfairSync extends Sync { private static final long serialVersionUID = -2694183684443567898L; NonfairSync(int permits) { super(permits); }
*** 236,246 **** } /** * Fair version */ ! final static class FairSync extends Sync { private static final long serialVersionUID = 2014338818796000944L; FairSync(int permits) { super(permits); } --- 236,246 ---- } /** * Fair version */ ! static final class FairSync extends Sync { private static final long serialVersionUID = 2014338818796000944L; FairSync(int permits) { super(permits); }
*** 280,290 **** * @param fair {@code true} if this semaphore will guarantee * first-in first-out granting of permits under contention, * else {@code false} */ public Semaphore(int permits, boolean fair) { ! sync = (fair)? new FairSync(permits) : new NonfairSync(permits); } /** * Acquires a permit from this semaphore, blocking until one is * available, or the thread is {@linkplain Thread#interrupt interrupted}. --- 280,290 ---- * @param fair {@code true} if this semaphore will guarantee * first-in first-out granting of permits under contention, * else {@code false} */ public Semaphore(int permits, boolean fair) { ! sync = fair ? new FairSync(permits) : new NonfairSync(permits); } /** * Acquires a permit from this semaphore, blocking until one is * available, or the thread is {@linkplain Thread#interrupt interrupted}.