Saturday, 24 August 2013

shutdown and awaitTermination which first call have any difference?

shutdown and awaitTermination which first call have any difference?

ExecutorService eService = Executors.newFixedThreadPool(2);
eService.execute(new TestThread6());
eService.execute(new TestThread6());
eService.execute(new TestThread6());
eService.awaitTermination(1, TimeUnit.NANOSECONDS);
eService.shutdown();
or
eService.shutdown();
eService.awaitTermination(1, TimeUnit.NANOSECONDS);
have any difference? and i don't really understand shutdown():This method
does not wait for previously submitted tasks to complete execution. it
means maybe shutdown() may terminate the task which have submited,but not
complete?but i try some examples not prove it,please give me a example.
appreciate for you helps and suggestion.

No comments:

Post a Comment