Interface ListeningExecutorService

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default boolean awaitTermination​(java.time.Duration timeout)
      Duration-based overload of ExecutorService.awaitTermination(long, TimeUnit).
      <T extends @Nullable java.lang.Object>
      java.util.List<java.util.concurrent.Future<T>>
      invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
      <T extends @Nullable java.lang.Object>
      java.util.List<java.util.concurrent.Future<T>>
      invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)
      default <T extends @Nullable java.lang.Object>
      java.util.List<java.util.concurrent.Future<T>>
      invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, java.time.Duration timeout)
      Duration-based overload of invokeAll(Collection, long, TimeUnit).
      default <T extends @Nullable java.lang.Object>
      T
      invokeAny​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, java.time.Duration timeout)
      Duration-based overload of ExecutorService.invokeAny(Collection, long, TimeUnit).
      ListenableFuture<?> submit​(java.lang.Runnable task)  
      <T extends @Nullable java.lang.Object>
      ListenableFuture<T>
      submit​(java.lang.Runnable task, T result)  
      <T extends @Nullable java.lang.Object>
      ListenableFuture<T>
      submit​(java.util.concurrent.Callable<T> task)  
      • Methods inherited from interface java.util.concurrent.Executor

        execute
      • Methods inherited from interface java.util.concurrent.ExecutorService

        awaitTermination, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow
    • Method Detail

      • submit

        <T extends @Nullable java.lang.Object> ListenableFuture<T> submit​(java.util.concurrent.Callable<T> task)
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
        Returns:
        a ListenableFuture representing pending completion of the task
        Throws:
        java.util.concurrent.RejectedExecutionException
      • submit

        ListenableFuture<?> submit​(java.lang.Runnable task)
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
        Returns:
        a ListenableFuture representing pending completion of the task
        Throws:
        java.util.concurrent.RejectedExecutionException
      • submit

        <T extends @Nullable java.lang.Object> ListenableFuture<T> submit​(java.lang.Runnable task,
                                                                          T result)
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
        Returns:
        a ListenableFuture representing pending completion of the task
        Throws:
        java.util.concurrent.RejectedExecutionException
      • invokeAll

        <T extends @Nullable java.lang.Object> java.util.List<java.util.concurrent.Future<T>> invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
                                                                                                 throws java.lang.InterruptedException

        All elements in the returned list must be ListenableFuture instances. The easiest way to obtain a List<ListenableFuture<T>> from this method is an unchecked (but safe) cast:

           @SuppressWarnings("unchecked") // guaranteed by invokeAll contract
           List<ListenableFuture<T>> futures = (List) executor.invokeAll(tasks);
         
        Specified by:
        invokeAll in interface java.util.concurrent.ExecutorService
        Returns:
        A list of ListenableFuture instances representing the tasks, in the same sequential order as produced by the iterator for the given task list, each of which has completed.
        Throws:
        java.util.concurrent.RejectedExecutionException
        java.lang.NullPointerException - if any task is null
        java.lang.InterruptedException
      • invokeAll

        <T extends @Nullable java.lang.Object> java.util.List<java.util.concurrent.Future<T>> invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                                                                                                        long timeout,
                                                                                                        java.util.concurrent.TimeUnit unit)
                                                                                                 throws java.lang.InterruptedException

        All elements in the returned list must be ListenableFuture instances. The easiest way to obtain a List<ListenableFuture<T>> from this method is an unchecked (but safe) cast:

           @SuppressWarnings("unchecked") // guaranteed by invokeAll contract
           List<ListenableFuture<T>> futures = (List) executor.invokeAll(tasks, timeout, unit);
         
        Specified by:
        invokeAll in interface java.util.concurrent.ExecutorService
        Returns:
        a list of ListenableFuture instances representing the tasks, in the same sequential order as produced by the iterator for the given task list. If the operation did not time out, each task will have completed. If it did time out, some of these tasks will not have completed.
        Throws:
        java.util.concurrent.RejectedExecutionException
        java.lang.NullPointerException - if any task is null
        java.lang.InterruptedException
      • invokeAll

        default <T extends @Nullable java.lang.Object> java.util.List<java.util.concurrent.Future<T>> invokeAll​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                                                                                                                java.time.Duration timeout)
                                                                                                         throws java.lang.InterruptedException
        Duration-based overload of invokeAll(Collection, long, TimeUnit).
        Throws:
        java.lang.InterruptedException
        Since:
        32.1.0
      • invokeAny

        default <T extends @Nullable java.lang.Object> T invokeAny​(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
                                                                   java.time.Duration timeout)
                                                            throws java.lang.InterruptedException,
                                                                   java.util.concurrent.ExecutionException,
                                                                   java.util.concurrent.TimeoutException
        Duration-based overload of ExecutorService.invokeAny(Collection, long, TimeUnit).
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
        Since:
        32.1.0
      • awaitTermination

        default boolean awaitTermination​(java.time.Duration timeout)
                                  throws java.lang.InterruptedException
        Duration-based overload of ExecutorService.awaitTermination(long, TimeUnit).
        Throws:
        java.lang.InterruptedException
        Since:
        32.1.0