changeset 42321:a0abf857aaec

8169272: Clarify Semaphore.drainPermits behavior when current permits are negative Reviewed-by: martin, smarks, psandoz
author dl
date Mon, 28 Nov 2016 23:43:39 -0800
parents bfc781c5078f
children c3474fef4fe4
files jdk/src/java.base/share/classes/java/util/concurrent/Semaphore.java
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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();