I'm trying to understand the contract of drainPermits in the Java Semaphore class
The JavaDoc simply reads:
public int drainPermits()
Acquire and return all permits that are immediately available. Returns: the number of permits
If no permits are currently available, does it block and wait until one is available?
No, it will return 0 immediately. It doesn't require any permits to be available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With