8169272: Clarify Semaphore.drainPermits behavior when current permits are negative
authordl
Mon, 28 Nov 2016 23:43:39 -0800
changeset 42321 a0abf857aaec
parent 42320 bfc781c5078f
child 42322 c3474fef4fe4
8169272: Clarify Semaphore.drainPermits behavior when current permits are negative Reviewed-by: martin, smarks, psandoz
jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java
--- a/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java	Mon Nov 28 23:39:54 2016 -0800
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java	Mon Nov 28 23:43:39 2016 -0800
@@ -631,9 +631,12 @@
     }
 
     /**
-     * Acquires and returns all permits that are immediately available.
+     * Acquires and returns all permits that are immediately
+     * available, or if negative permits are available, releases them.
+     * Upon return, zero permits are available.
      *
-     * @return the number of permits acquired
+     * @return the number of permits acquired or, if negative, the
+     * number released
      */
     public int drainPermits() {
         return sync.drainPermits();