What is thread pool? Why should we use thread pools?

Ans: A thread pool is a collection of threads on which task can be scheduled. Instead of creating a new thread for each task, you can have one of the threads from the thread pool pulled out of the pool and assigned to the task. When the thread is finished with the task, it adds itself back to the pool and waits for another assignment. One common type of thread pool is the fixed thread pool. This type of pool always has a specified number of threads running; if a thread is somehow terminated while it is still in use, it is automatically replaced with a new thread. Below are key reasons to use a Thread Pool
  • Using thread pools minimizes the JVM overhead due to thread creation. Thread objects use a significant amount of memory, and in a large-scale application, allocating and de-allocating many thread objects creates a significant memory management overhead.
  • You have control over the maximum number of tasks that are being processed in parallel (= number of threads in the pool).
Most of the executor implementations in java.util.concurrent use thread pools, which consist of worker threads. This kind of thread exists separately from the Runnable and Callable tasks it executes and is often used to execute multiple tasks.

People who read this post also read :


Nice post,Its very interesting and very helpful for us.Thank you for sharing it with us.

finally clear my doubt...thanks

now i know exactly about Tread pool...Thanks

This is a great article, I have been always to read something with specific tips! I will have to work on the time for scheduling my learning.
Billing Software in chennai

Hi there :) I will be implementing my first erp fairly soon, and I just can't wait to see how it's going to be like! I decided to get this one: https://ax-dynamics.com/dynamics-365/for-operations, what do you think about it?

myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

Post a Comment


Twitter Delicious Facebook Digg Stumbleupon Favorites More