标签: java concurrency
我正在尝试理解Java Semaphore类中的drainPermits的合同
JavaDoc只读:
public int drainPermits() Acquire and return all permits that are immediately available. Returns: the number of permits
public int drainPermits()
Acquire and return all permits that are immediately available. Returns: the number of permits
如果目前没有许可证,它是否会阻止并等待一个许可证可用?
答案 0 :(得分:9)
不,它会立即返回0。它不需要任何许可证。