What are the advantages of using an ExecutorService?

前端 未结 8 1066
孤城傲影
孤城傲影 2020-11-27 12:45

What is the advantage of using ExecutorService over running threads passing a Runnable into the Thread constructor?

8条回答
  •  猫巷女王i
    2020-11-27 13:38

    Creating a large number of threads with no restriction to the maximum threshold can cause application to run out of heap memory. Because of that creating a ThreadPool is much better solution. Using ThreadPool we can limit the number of threads can be pooled and reused.

    Executors framework facilitate process of creating Thread pools in java. Executors class provide simple implementation of ExecutorService using ThreadPoolExecutor.

    Source:

    What is Executors Framework

提交回复
热议问题