1.

What Is Executor In Java Concurrency?

Answer»

The concurrent API has a feature called executors that provides an alternative to managing threads through the Thread CLASS. At the CORE of the executors is the Executor interface - An object of type Executor can execute runnable tasks. An Executor is NORMALLY used instead of EXPLICITLY creating threads.

For example If r is a Runnable object, and e is an Executor object you can replace

(NEW Thread(r)).start();
with
e.execute(r);

The Executor interface provides a single method, execute -

void execute(Runnable command)

The concurrent API has a feature called executors that provides an alternative to managing threads through the Thread class. At the core of the executors is the Executor interface - An object of type Executor can execute runnable tasks. An Executor is normally used instead of explicitly creating threads.

For example If r is a Runnable object, and e is an Executor object you can replace

(new Thread(r)).start();
with
e.execute(r);

The Executor interface provides a single method, execute -

void execute(Runnable command)



Discussion

No Comment Found