Relative Content

Tag Archive for javamultithreadingthreadpoolexecutorservice

ExecutorService awaitTermination does not wait for threads to complete and terminates main thread immediately

I have created a ExecutorService having 3 threads using which I’m trying to process a list each having 2MM objects. I’m calling executorService.shutdown(); and executorService.awaitTermination(20, TimeUnit.HOURS) after submitting the 3 tasks. However, once the 3 threads start execution, the main thread terminates without waiting for the processing threads to complete execution. What am I missing?