Example usage for org.apache.commons.lang3.concurrent TimedSemaphore TimedSemaphore

List of usage examples for org.apache.commons.lang3.concurrent TimedSemaphore TimedSemaphore

Introduction

In this page you can find the example usage for org.apache.commons.lang3.concurrent TimedSemaphore TimedSemaphore.

Prototype

public TimedSemaphore(final long timePeriod, final TimeUnit timeUnit, final int limit) 

Source Link

Document

Creates a new instance of TimedSemaphore and initializes it with the given time period and the limit.

Usage

From source file:ch.cyberduck.core.bonjour.LimitedRendezvousListener.java

public LimitedRendezvousListener(final Set<RendezvousListener> listeners) {
    this(new TimedSemaphore(1L, TimeUnit.MINUTES,
            PreferencesFactory.get().getInteger("rendezvous.notification.limit")), listeners);
}

From source file:org.opensilk.video.data.LookupService.java

protected static synchronized void waitTurn() {
    try {//  w  ww . j  a  v a2s .  c  om
        if (sSemaphore.isShutdown()) {
            sSemaphore = new TimedSemaphore(WAIT_TIME, TimeUnit.MILLISECONDS, WAIT_USERS);
        }
        sSemaphore.acquire();
    } catch (InterruptedException e) {
        Timber.w("Interrupted while waiting on semaphore");
    }
}