/** * * @param task * The task to submit. * @param result * The result to return. * @return A Future representing pending completion of the task, and whose * get() method will return the given result upon completion. */ public <T> Future<T> submit(Runnable task, T result) { startIfNeeded(); return getWrapped().submit(task, result); }
/** * Executes the given command asynchronously. * * @param command * The command to execute. */ public void execute(Runnable command) { startIfNeeded(); getWrapped().execute(command); }
/** * * @param task * The task to submit. * @return A Future representing pending completion of the task, and whose * get() method will return the given result upon completion. */ public Future<?> submit(Runnable task) { startIfNeeded(); return getWrapped().submit(task); }
/** * Submits a value-returning task for execution and returns a Future * representing the pending results of the task. * * @param task * The task to submit. * @return A Future representing pending completion of the task, and whose * get() method will return the given result upon completion. */ public <T> Future<T> submit(Callable<T> task) { startIfNeeded(); return getWrapped().submit(task); }
/** * Blocks until all tasks have completed execution after a shutdown request, * or the timeout occurs, or the current thread is interrupted, whichever * happens first. * * @param timeout * The maximum time to wait. * @param unit * The time unit. * @return True if this executor terminated and false if the timeout elapsed * before termination. */ public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException { startIfNeeded(); return getWrapped().awaitTermination(timeout, unit); }
/** * Creates and executes a one-shot action that becomes enabled after the * given delay. * * @param command * The task to execute. * @param delay * The time from now to delay execution. * @param unit * The time unit of the delay parameter. * @return a Future representing pending completion of the task, and whose * <tt>get()</tt> method will return <tt>null</tt> upon completion. * @throws RejectedExecutionException * if task cannot be scheduled for execution. * @throws NullPointerException * if command is null */ public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) { startIfNeeded(); return getWrapped().schedule(command, delay, unit); }
/** * Creates and executes a ScheduledFuture that becomes enabled after the * given delay. * * @param callable * The function to execute. * @param delay * The time from now to delay execution. * @param unit * The time unit of the delay parameter. * @return a ScheduledFuture that can be used to extract result or cancel. * @throws RejectedExecutionException * if task cannot be scheduled for execution. * @throws NullPointerException * if callable is null */ public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { startIfNeeded(); return getWrapped().schedule(callable, delay, unit); }
startIfNeeded(); return getWrapped().scheduleWithFixedDelay(command, initialDelay, delay, unit);
startIfNeeded(); return getWrapped().scheduleAtFixedRate(command, initialDelay, period, unit);
/** * Executes the given tasks, returning a list of Futures holding their * status and results when all complete.<br> * <br> * Due to a breaking change between Java SE versions 5 and 6, and in order * to maintain compatibility both at the source and binary level, we have * removed the generic information from this method. You can check the * {@link ExecutorService} interface for typing details. * * @param tasks * The task to execute. * @return The list of futures. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public List invokeAll(Collection tasks) throws InterruptedException { startIfNeeded(); return getWrapped().invokeAll(tasks); }
/** * Executes the given tasks, returning the result of one that has completed * successfully (i.e., without throwing an exception), if any do. Upon * normal or exceptional return, tasks that have not completed are * cancelled. The results of this method are undefined if the given * collection is modified while this operation is in progress. * * Due to a breaking change between Java SE versions 5 and 6, and in order * to maintain compatibility both at the source and binary level, we have * removed the generic information from this method. You can check the * {@link ExecutorService} interface for typing details. * * @param tasks * The task to execute. * @return The result returned by one of the tasks. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public Object invokeAny(Collection tasks) throws InterruptedException, ExecutionException { startIfNeeded(); return getWrapped().invokeAny(tasks); }
/** * Executes the given tasks, returning a list of Futures holding their * status and results when all complete or the timeout expires, whichever * happens first. Future.isDone() is true for each element of the returned * list. Upon return, tasks that have not completed are canceled. Note that * a completed task could have terminated either normally or by throwing an * exception. The results of this method are undefined if the given * collection is modified while this operation is in progress.<br> * <br> * Due to a breaking change between Java SE versions 5 and 6, and in order * to maintain compatibility both at the source and binary level, we have * removed the generic information from this method. You can check the * {@link ExecutorService} interface for typing details. * * @param tasks * The task to execute. * @param timeout * The maximum time to wait. * @param unit * The time unit. * @return The list of futures. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public List invokeAll(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException { startIfNeeded(); return getWrapped().invokeAll(tasks, timeout, unit); }
/** * Executes the given tasks, returning the result of one that has completed * successfully (i.e., without throwing an exception), if any do before the * given timeout elapses. Upon normal or exceptional return, tasks that have * not completed are cancelled. The results of this method are undefined if * the given collection is modified while this operation is in progress. * * Due to a breaking change between Java SE versions 5 and 6, and in order * to maintain compatibility both at the source and binary level, we have * removed the generic information from this method. You can check the * {@link ExecutorService} interface for typing details. * * @param tasks * The task to execute. * @param timeout * The maximum time to wait. * @param unit * The time unit. * @return The result returned by one of the tasks. */ @SuppressWarnings({ "rawtypes", "unchecked" }) public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { startIfNeeded(); return getWrapped().invokeAny(tasks, timeout, unit); }