What is the difference between
ExecutorService eService = Executors.newFixedThreadPool(2);
eService.execute(new TestThread6());
eService.execute(new TestThread6());
eService.execute(new TestThread6());
eService.awaitTermination(1, TimeUnit.NANOSECONDS);
eService.shutdown();
and
eService.shutdown();
eService.awaitTermination(1, TimeUnit.NANOSECONDS);
I don't really understand shutdown()
. This method does not wait for previously submitted tasks to complete execution. Does it mean shutdown()
may terminate the tasks which have been submitted, but not completed? I tried some examples, they do not prove it, please give me an example.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…