public <T>ScheduledFuture<?> schedule(Callable<T> callable,long delay,TimeUnit unit){
synchronized (this) {
    if (future == null || future.isCancelled() || future.isDone() || future.getDelay(unit) > delay) {
      if (future != null && !future.isDone()) {
        future.cancel(false);
        listener.taskDropped();
      }
      future=ex.schedule(new DelegatingCallable<T>(callable),delay,unit);
    }
 else {
      listener.taskDropped();
    }
  }
  return future;
}

public < T > ScheduledFuture < ? > schedule ( Callable < T > callable , long delay , TimeUnit unit ) { synchronized ( this ) { if ( future == null || future . isCancelled ( ) || future . isDone ( ) || future . getDelay ( unit ) > delay ) { if ( future != null && ! future . isDone ( ) ) { future . cancel ( false ) ; listener . taskDropped ( ) ; } future = ex . schedule ( new DelegatingCallable < T > ( callable ) , delay , unit ) ; } else { listener . taskDropped ( ) ; } } return future ; }
schedule an execution of a task . this will either add the task to the execution service , or if a task has already been scheduled through this decorator and is still pending execution it will return the future associated with the previously scheduled task .
