Executors: How to synchronously wait until all tasks have finished if tasks are created recursively?

前端 未结 9 1426
傲寒
傲寒 2020-12-31 09:37

My question is strongly related to this one here. As was posted there, I would like the main thread to wait until the work queue is empty and all tasks have finished. The pr

9条回答
  •  醉梦人生
    2020-12-31 10:07

    If you know number of threads to wait and can paste one line of code to increase number for each thread with help of CountDownLatch ( http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/CountDownLatch.html ) It can resolve you problem

提交回复
热议问题