What are the advantages of using an ExecutorService?

前端 未结 8 1051
孤城傲影
孤城傲影 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:16

    Below are some benefits:

    1. Executor service manage thread in asynchronous way
    2. Use Future callable to get the return result after thread completion.
    3. Manage allocation of work to free thread and resale completed work from thread for assigning new work automatically
    4. fork - join framework for parallel processing
    5. Better communication between threads
    6. invokeAll and invokeAny give more control to run any or all thread at once
    7. shutdown provide capability for completion of all thread assigned work
    8. Scheduled Executor Services provide methods for producing repeating invocations of runnables and callables Hope it will help you

提交回复
热议问题