How can I check whether all tasks submitted to ThreadPoolExecutor are completed?
New tasks can be added from previously submitted tasks, so I can't call shutdown followed by awaitTermination nor invokeAll, as it will ignore these new tasks.
yourThreadPoolExecutor.getActiveCount(); will return 0 when all tasks have completed.
You can use ThreadPoolExecutor.getCompletedTaskCount()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With