Example usage for java.util.concurrent TimeUnit timedWait

List of usage examples for java.util.concurrent TimeUnit timedWait

Introduction

In this page you can find the example usage for java.util.concurrent TimeUnit timedWait.

Prototype

public void timedWait(Object obj, long timeout) throws InterruptedException 

Source Link

Document

Performs a timed Object#wait(long,int) Object.wait using this time unit.

Usage

From source file:org.apache.geode.distributed.LocatorLauncher.java

private void timedWait(final long interval, final TimeUnit timeUnit) {
    try {/*w  w w  . j av a  2  s  .  co  m*/
        synchronized (this) {
            timeUnit.timedWait(this, interval);
        }
    } catch (InterruptedException handled) {
        // NOTE just go and send another status request to the Locator...
    }
}

From source file:org.apache.hadoop.hbase.client.ResultBoundedCompletionService.java

/**
 * Poll for the Nth completed task (index starts from 0 (the 1st), 1 (the second)...)
 *
 * @param timeout  - time to wait before it times out
 * @param unit  - time unit for timeout/*from w w  w  .  j a  v  a  2 s .c  om*/
 * @param index - the index(th) completed task, index starting from 0
 */
private QueueingFuture<V> pollForSpecificCompletedTask(long timeout, TimeUnit unit, int index)
        throws InterruptedException {
    if (index < 0) {
        return null;
    }

    synchronized (tasks) {
        if (!cancelled && (completedTasks.size() <= index))
            unit.timedWait(tasks, timeout);
        if (completedTasks.size() <= index)
            return null;
    }
    return completedTasks.get(index);
}