How Threadpool re-use Threads and how it works

后端 未结 4 1504
清酒与你
清酒与你 2020-11-30 03:17

My multithreading concepts are weak and trying to learn.

In Java what I know is, we can\'t call a thread more than once:

Thread t = new Thread; //So         


        
4条回答
  •  有刺的猬
    2020-11-30 03:36

    In Thread Pool Instead of creating new threads when new tasks arrive, a thread pool keeps a number of idle threads that are ready for executing tasks as needed. After a thread completes execution of a task, it does not die. Instead it remains idle in the pool waiting to be chosen for executing new tasks.

    You can limit a definite number of concurrent threads in the pool, which is useful to prevent overload. If all threads are busily executing tasks, new tasks are placed in a queue, waiting for a thread becomes available

提交回复
热议问题