What is the difference between
ExecutorService eService = Executors.newFixedThreadPool(2);
eService.execute(new TestThread6());
eService.execute(new TestThre
executorService.execute(runnableTask);
//executorService.shutdown(); //it will make the executorService stop accepting new tasks
//executorService.shutdownNow(); //tires to destroy the executorService immediately, but it doesn't guarantee that all the running threads will be destroyed at the same time. This method returns list of tasks which are waiting to be processed.
//List notExecutedTasks = executorService.shutdownNow(); //this method returns list of tasks which are waiting to be processed.developer decide what to do with theses tasks?
//one good way to shutdown the executorService is use both of these methods combined with the awaitTermination
executorService.shutdown();
try{
if(!executorService.awaitTermination(1000, TimeUnit.MICROSECONDS)) {
executorService.shutdownNow();
}
}catch (InterruptedException e){
e.printStackTrace();
}