Java Executor Interface

Category: Java   Tags: Java, Java Thread, Java MultiThread, Thread Synchronization, Immutable Objects, Java Concurrent Collection

The java.util.concurrent package defines three executor interfaces:

The Executor Interface

Executor interface has one method:

                          void execute(Runnable thread)
                        

execute start the specified thread mentioned by thread.

The ExecutorService Interface

The ExecutorService interface extends Executor. Just like execute method ExecutorService provides a similar, but more versatile submit method. Its has following form:

                                  <T> Future<T> submit(Callable<T> task)
                                

The submit method returns a Future object. Future object is used to retrieve the Callable return value and to manage the status of both Callable and Runnable tasks.

The ScheduledExecutorService Interface

It has a method schedule, which executes a RCallable or Runnable task after a specified delay.