public int drainPermits():
Acquires and returns all permits that are immediately available. Returns: the number of permits acquired.
Why would someone want to acquire and then immediately release all available permits from a Semaphore? If they want to see the number of available permits, why not use Semaphore.availablePermits()?
It doesn’t release them. It acquires them all, that’s all: