Executor

In the java.util.concurrent package, there are a bunch of interfaces dedicated to executing tasks. The simplest one is named Executor. This interface exposes a single method named execute​(Runnable command). Here is an example of executing a single task using this method:

public class SimpleExecutor implements Executor {

@Override
public void execute(Runnable r) {
(new Thread(r)).start();
}
}

SimpleExecutor se = new SimpleExecutor();

se.execute(() -> {
System.out.println("Simple task executed via Executor interface");
});
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.197.95