This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes container managed Thread pool Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "container managed Thread pool" Watch "container managed Thread pool" New topic

container managed Thread pool

S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
Hi everybody ,

What is container managed Thread pool and how actually it is working ?

Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1071

First let us understand
what is Thread pool
Thread pool is concept where in a pre-defined number of threads can be created/initialized in advance (for example, during server start up) and stored in virtual memory. Threads are created in advance because this reduces the amount of resources required to create new threads at run time. So, Thread pool eliminate the need to create new threads at runtime. Advantage of Thread pool is that it allows components of application server to reuse threads.

Now we come to 'Container managed'.
For any web application, Thread pool concept can be implemented either by Web Application Developers OR it can be implemented by 'Application Server(container)' that we are using to host our web application. So, for any webapplication, if conatiner manages thread pool for us, then, we are said to be using 'container managed thread pool'.

How container manages Thread pool ?
The container has a thread pool and a request queue. When a request comes in, it's added to the queue. A listener takes the request off the queue, checks a thread out of the thread pool, and gives it the request to process. When the process is complete, the thread goes back into the pool to await its next assignment.When the thread pool is exhausted (all thread are busy in catering other requests), requests back up in the queue until sufficient resources are available to process them.

Hope this explanation helps you in basics of container managed thread pool

~ abhay
S Majumder
Ranch Hand

Joined: Jun 03, 2009
Posts: 244
Thanks Abhay Agarwal for your reply .

How Developers create those threads on the fly ?

Don't get me started about those stupid light bulbs.
subject: container managed Thread pool
Similar Threads
A question about 'single-threaded mode'
Container Managed Thread Pool
Application vs Container Managed Connection Pool
Servlet Thread Killing.
How are Servlets and objects in it instantiated?