title: Awaitility.await().atMost(...) causes program to exit if time out interval expires?
body: <p>This question regards com.jayway.awaitility.Awaitility.</p>
  
  <p>I just tried Awaitility.await() and it seems to have some odd behavior.
  In the test method below if I comment out testWithFuture() and enable 
  testWithAwaitility(),  I never  see the message  "end " printed out.
  I see 'start ', then the program just exits, and the second
  print statement never seems to be reached.</p>
  
  <p>So as a work around I decided to use Settable{Future}..  If anyone else has the same issue then maybe the work-around I provide will be useful.. Even better would be to get a nice answer ;^)      !  thanks in advance  / chris </p>
  
  <p>THE CODE: </p>
  
  <pre><code>
  import com.google.common.util.concurrent.SettableFuture;
  
  import java.util.Date;
  import java.util.concurrent.Callable;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.TimeUnit;
  import java.util.concurrent.TimeoutException;
  
  import static com.jayway.awaitility.Awaitility.await;
  import static java.util.concurrent.TimeUnit.SECONDS;
  
  public class AwaitTest {
      static volatile boolean done = false;
  
      public static void main(String[] args) throws InterruptedException, ExecutionException, TimeoutException {
          testWithFuture();
          //testWithAwaitility();
      }
  
      private static void testWithAwaitility() {
          System.out.println("start " + new Date());
          new Thread(new Runnable(){
              public void run(){
                  try {
                      Thread.sleep(5000);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
                  done = true;
              }
  
          }).start();
  
  
          await().atMost(2, SECONDS).until(new Callable() {
              @Override
              public Boolean call() throws Exception {
                  return done;
              }
          });
  
          System.out.println("end " + new Date());   // NEVER Reached. i wonder why?
  
      }
  
      // This does what I want.
      //
      private static void testWithFuture() throws InterruptedException, ExecutionException, TimeoutException {
          System.out.println("start testWithFuture");
  
          final SettableFuture future = SettableFuture. create();
          new Thread(new Runnable(){
  
              public void run(){
                  try {
                      Thread.sleep(5000);
                  } catch (InterruptedException e) {
                      e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                  }
                  future.set("Hello");
              }
  
          }).start();
  
          String result = future.get(4, TimeUnit.SECONDS);
  
          if (! result.equals("Hello")) {
              throw new RuntimeException("not equal");
          } else {
              System.out.println("got Hello");
  
          }
      }
   }
  </code></pre>
  
  <p>CORRECTED CODE -> </p>
  
  <pre><code>import java.util.Date;
  import java.util.concurrent.Callable;
  import java.util.concurrent.ExecutionException;
  import java.util.concurrent.TimeUnit;
  import java.util.concurrent.TimeoutException;
  
  import static com.jayway.awaitility.Awaitility.await;
  import static java.util.concurrent.TimeUnit.SECONDS;
  
  public class Sample {
      static volatile boolean done = false;
  
      public static void main(String[] args) {
          testWithAwaitility();
      }
  
      private static void testWithAwaitility() {
          System.out.println("start " + new Date());
          new Thread(new Runnable(){
              public void run(){
                  try {
                      Thread.sleep(5000);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
                  done = true;
              }
  
          }).start();
  
  
          try {
              await().atMost(2, SECONDS).until(new Callable() {
                  @Override
                  public Boolean call() throws Exception {
                      return done;
                  }
              });
          } catch (Exception e) {
              System.out.println("FAILED");
              e.printStackTrace();
          }
  
  
          System.out.println("end " + new Date());   // REACHED this statement after correction
      }
   }
  </code></pre>