java thread reuse

后端 未结 4 1970
不知归路
不知归路 2020-12-02 10:21

I have always read that creating threads is expensive.
I also know that you cannot rerun a thread.

I see in the doc of Executors class:

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 11:01

    A thread pool creates its own threads and supplies its own clever little Runnables for those threads. Those Runnables never end but synchronize on a queue (they wait()) until a Callable is present in that queue; they are notified when that happens and their Runnable runs the Callable from the queue and the entire scenario repeats itself again.

提交回复
热议问题