SingleThreadExecutor VS plain thread

前端 未结 4 1853
盖世英雄少女心
盖世英雄少女心 2021-02-11 19:08

Apart from the fact that the Executor interface has some advantages over plain threads (management, for example), is there any real internal difference (big perform

4条回答
  •  孤独总比滥情好
    2021-02-11 19:52

    If you only get one Runnable to execute, then there is no big difference between them.

    Using plain thread may be a little more efficient because creating an ExecutorService such as ThreadPoolExecutor has something to do besides creating a new thread. For example, creating blocking queue, creating policy, though these things are done implicitly.

    And you have to shutdown the executor after this runnable has been executed. Otherwise the single thread in this pool will never exit.

提交回复
热议问题