View Javadoc

1   package com.atlassian.util.concurrent;
2   
3   import java.util.concurrent.TimeUnit;
4   
5   /**
6    * Something that can be awaited upon.
7    * 
8    * @author Jed Wesley-Smith
9    */
10  public interface Awaitable {
11  
12      /**
13       * Await for the condition to become true.
14       * 
15       * @throw {@link InterruptedException} if {@link Thread#interrupt()
16       * interrupted}
17       */
18      void await() throws InterruptedException;
19  
20      /**
21       * Await for the specified time for the condition to become true.
22       * 
23       * @param time the amount to wait.
24       * @param unit the unit to wait in.
25       * @throw {@link InterruptedException} if {@link Thread#interrupt()
26       * interrupted}
27       * @return true if the condition became true within the time limit, false
28       * otherwise.
29       */
30      boolean await(long time, TimeUnit unit) throws InterruptedException;
31  }