/** * Returns the number of calls to the {@link #acquire()} method that can * still be performed in the current period without blocking. This method * can give an indication whether it is safe to call the {@link #acquire()} * method without risking to be suspended. However, there is no guarantee * that a subsequent call to {@link #acquire()} actually is not-blocking * because in the mean time other threads may have invoked the semaphore. * * @return the current number of available {@link #acquire()} calls in the * current period */ public synchronized int getAvailablePermits() { return getLimit() - getAcquireCount(); }
.getAcquireCount()); t.join(); assertEquals("Wrong semaphore count (2)", 1, semaphore .getAcquireCount()); assertEquals("Wrong acquire() count", count - 1, semaphore .getLastAcquiresPerPeriod());
/** * Returns the number of calls to the {@link #acquire()} method that can * still be performed in the current period without blocking. This method * can give an indication whether it is safe to call the {@link #acquire()} * method without risking to be suspended. However, there is no guarantee * that a subsequent call to {@link #acquire()} actually is not-blocking * because in the mean time other threads may have invoked the semaphore. * * @return the current number of available {@link #acquire()} calls in the * current period */ public synchronized int getAvailablePermits() { return getLimit() - getAcquireCount(); }
/** * Returns the number of calls to the {@link #acquire()} method that can * still be performed in the current period without blocking. This method * can give an indication whether it is safe to call the {@link #acquire()} * method without risking to be suspended. However, there is no guarantee * that a subsequent call to {@link #acquire()} actually is not-blocking * because in the mean time other threads may have invoked the semaphore. * * @return the current number of available {@link #acquire()} calls in the * current period */ public synchronized int getAvailablePermits() { return getLimit() - getAcquireCount(); }
/** * Returns the number of calls to the {@link #acquire()} method that can * still be performed in the current period without blocking. This method * can give an indication whether it is safe to call the {@link #acquire()} * method without risking to be suspended. However, there is no guarantee * that a subsequent call to {@link #acquire()} actually is not-blocking * because in the mean time other threads may have invoked the semaphore. * * @return the current number of available {@link #acquire()} calls in the * current period */ public synchronized int getAvailablePermits() { return getLimit() - getAcquireCount(); }