What are the advantages of using an ExecutorService?

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

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

8条回答
  •  悲&欢浪女
    2020-11-27 13:14

    Prior to java 1.5 version, Thread/Runnable was designed for two separate services

    1. Unit of work
    2. Execution of that unit of work

    ExecutorService decouples those two services by designating Runnable/Callable as unit of work and Executor as a mechanism to execute ( with lifecycling) the unit of work

提交回复
热议问题