I use something like this in order to run an ExecutorService and await termination of the task
ExecutorService
ExecutorService taskExecutor = Executors.newFixedThrea