com.h3c.util.concurrent

## Class Blocker

- java.lang.Object
- - com.h3c.util.concurrent.Blocker

-     public final class Blocker
      extends Object

  A class that blocks the current thread until some condition or predicate is met.

  This class should be used when the condition has to be evaluated and a notification is not possible; if it is possible to get a notification when the condition may change `Object.wait()` and `Object.notify()`/ `Object.notifyAll()` should be used instead.

  If the thread does not need to be blocked, but a condition change notification is still not possible, use `Waiter` instead.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `wait(Predicate<Void> condition, javax.measure.Measurable<javax.measure.quantity.Duration> evaluationPeriod, Integer maxEvaluations)` Blocks the current thread until the predicate or condition becomes `true`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### wait

          public static void wait(Predicate<Void> condition,
                  javax.measure.Measurable<javax.measure.quantity.Duration> evaluationPeriod,
                  Integer maxEvaluations)
                           throws InterruptedException

      Blocks the current thread until the predicate or condition becomes `true`.
      Parameters:
        `condition` - condition (or predicate) to evaluate
        `evaluationPeriod` - period between evaluations (time the thread will be in sleep mode until a new evaluation is performed)
        `maxEvaluations` - maximum number of evaluations, `null` to evaluate until the predicate or condition becomes `true`
      Throws:
        `InterruptedException` - if any thread has interrupted the current thread.

Copyright © 2014. All Rights Reserved.