|Constructor and Description|
|Modifier and Type||Method and Description|
Acquire permits on the given semaphore within a given allowed timeout and deal with errors.
public static void tryAcquire(int permits, int maxConcurrentRequests, java.time.Duration maxConcurrentRequestsTimeout, Semaphore semaphore) throws InterruptedException, TimeoutException
permits- the mumber of permits to acquire.
maxConcurrentRequests- the maximum number of permits the semaphore was initialized with.
maxConcurrentRequestsTimeout- the timeout to acquire the permits.
semaphore- the semaphore to acquire permits to.
InterruptedException- if the current thread was interrupted.
TimeoutException- if the waiting time elapsed before all permits were acquired.
Copyright © 2014–2023 The Apache Software Foundation. All rights reserved.