You should call shutdown
first. Otherwise, you might be waiting for a very long time, since awaitTermination
doesn’t actually shut down your executor.
If you wanted to wait for tasks to complete, rather than wait for the executor to shut down, then you should use invokeAll
.