8169272: Clarify Semaphore.drainPermits behavior when current permits are negative
Reviewed-by: martin, smarks, psandoz
--- 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();