Example usage for com.google.common.util.concurrent Monitor enterWhen

List of usage examples for com.google.common.util.concurrent Monitor enterWhen

Introduction

In this page you can find the example usage for com.google.common.util.concurrent Monitor enterWhen.

Prototype

public void enterWhen(Guard guard) throws InterruptedException 

Source Link

Document

Enters this monitor when the guard is satisfied.

Usage

From source file:org.apache.jackrabbit.oak.segment.SegmentBufferWriterPool.java

/**
 * Same as {@code monitor.enterWhen(guard)} but copes with that pesky {@code
 * InterruptedException} by catching it and setting this thread's
 * interrupted flag.//from  w  w  w .j av  a  2 s .c o m
 */
private static boolean safeEnterWhen(Monitor monitor, Guard guard) {
    try {
        monitor.enterWhen(guard);
        return true;
    } catch (InterruptedException ignore) {
        Thread.currentThread().interrupt();
        return false;
    }
}