public boolean cancel(boolean mayInterruptIfRunning) { if (future == null) throw new UnsupportedOperationException( "You cannot cancel this task before calling future()"); return future.cancel(mayInterruptIfRunning); }
protected <T> T timedCall(Callable<T> c, long timeout, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException { FutureTask<T> task = new FutureTask<T>(c); try { THREAD_POOL.execute(task); return task.get(timeout, timeUnit); } finally { task.cancel(true); } }