Example usage for java.lang Long wait

List of usage examples for java.lang Long wait

Introduction

In this page you can find the example usage for java.lang Long wait.

Prototype

public final native void wait(long timeoutMillis) throws InterruptedException;

Source Link

Document

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

Usage

From source file:org.alfresco.bm.event.DelayingSampleEventProcessor.java

@Override
public EventResult processEvent(Event event) throws Exception {
    boolean fail = (Math.random() * 100) < failurePercent;
    long time = getValue(minTime, maxTime);

    Long mutex = new Long(0);
    synchronized (mutex) {
        mutex.wait(time);
    }// w w  w  .ja v  a 2 s  . com

    if (fail) {
        return new EventResult("Sample must fail " + failurePercent + "% of the time.", false);
    } else {
        Event outputEvent = new Event(outputEventName, null);
        return new EventResult("Sample must succeed " + (100 - failurePercent) + "% of the time.", outputEvent);
    }
}