Code example for ScheduledExecutorService

Methods: schedule

0
    @Override 
    public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
        if (ses == null)
            ses = Executors.newScheduledThreadPool(1);
        try { 
            return ses.schedule(command, delay, unit);
        } catch (Exception e) {
            return new MockFuture<Object>(new ExecutionException(e));
        } 
    } 
 
    @Override 
    public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay,
            TimeUnit unit) {
        if (ses == null)
            ses = Executors.newScheduledThreadPool(1);
        try { 
            return ses.schedule(callable, delay, unit);
        } catch (Exception e) {
            return new MockFuture<V>(new ExecutionException(e));
        }