Monday, May 16, 2016

Thread Pool

Creating a Thread is expensive as it requires a few hundred milliseconds to create a new one. Additionally each thread requires atleast around 1MB of data. So instead of creating and destroying a thread each time we could just create a collection of preinstantiated threads and use them instead. Whenever we require a thread we ask thread pool for a thread which we can use and when we are done with it instead of destroying it we can send it back to the collection for recycling. This way we avoid the cost it incurs for creating and destroying threads. This collection of preinstantiated thread is called a Thread Pool.

No comments:

Post a Comment

Code Formater

Paste Here Your Source Code
Source Code Formatting Options
1) Convert Tab into Space :
2) Need Line Code Numbering :
3) Remove blank lines :
4) Embeded styles / Stylesheet :
5) Code Block Width :
6) Code Block Height :
7) Alternative Background :
Copy Formatted Source Code
 
Preview Of Formatted Code