Waiting for all the threads to finish before shutting down the Executors

后端 未结 3 633
执念已碎
执念已碎 2020-12-18 12:05

Here is my code snippet.

ExecutorService executor = Executors.newFixedThreadPool(ThreadPoolSize);
while(conditionTrue)
{
ClassImplementingRunnable c = new Cl         


        
3条回答
  •  攒了一身酷
    2020-12-18 12:47

    What i want to achieve here is that i want to wait for all the threads in the threadpool to have finished the execution and then i want to shutdown the executor.

    That is what executor.shutdown(); does. If you want to shutdown immediately you need to use shutdownNow()

提交回复
热议问题