I have a thread pool created using
java.util.concurrent.ThreadPoolExecutor
Is there anyway I can wait till the pool is idle? By which I mean all the threads are not running and nothing is waiting in the queue.
I searched the web and all the solutions don't work for me. For example, I don't want shutdown the pool so awaitTermination() wouldn't work. I also know how to getTaskCount() but I don't want keep polling the pool, which wastes CPU.
This is a large project and I don't want change all the tasks running in the pool so I am looking for some solution that don't rely on task cooperation. So latches or barriers don't work for me.