@Test public void runIsSynchronous() throws Exception { final long timeout = 5000; Callable<Boolean> task = new Callable<Boolean>() { @Override public Boolean call() throws Exception { Thread.sleep(timeout); return false; } }; long startTime = System.currentTimeMillis(); Boolean result = AsyncRunner.run(task); long endTime = System.currentTimeMillis(); assertThat(result, is(false)); assertThat(endTime - startTime, greaterThanOrEqualTo(timeout)); }
public static <RESULT> RESULT run(Callable<RESULT> task) throws ExecutionException, InterruptedException { return submit(null, task).get().unwrap(); }
AsyncRunner { public static <RESULT> RESULT run(Callable<RESULT> task) throws ExecutionException, InterruptedException { return submit(null, task).get().unwrap(); } }
AsyncRunner { public static <RESULT> RESULT run(Callable<RESULT> task) throws ExecutionException, InterruptedException { return submit(null, task).get().unwrap(); } private  AsyncRunner(); }
AsyncRunner { public static <RESULT> RESULT run(Callable<RESULT> task) throws ExecutionException, InterruptedException { return submit(null, task).get().unwrap(); } private  AsyncRunner(); static Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task); static RESULT run(Callable<RESULT> task); static RESULT run(Callable<RESULT> task, long timeout, TimeUnit unit); static void setExecutor(AsyncExecutor executor); }
AsyncRunner { public static <RESULT> RESULT run(Callable<RESULT> task) throws ExecutionException, InterruptedException { return submit(null, task).get().unwrap(); } private  AsyncRunner(); static Future<AsyncResult<RESULT>> submit(Callback<RESULT> callback, Callable<RESULT> task); static RESULT run(Callable<RESULT> task); static RESULT run(Callable<RESULT> task, long timeout, TimeUnit unit); static void setExecutor(AsyncExecutor executor);  }