Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Connection pooling Vs Thread Pooling

  Asked By: Cory    Date: Jul 15    Category: Java    Views: 1877
  

i have implement connection
pooling in my project but now i want to impelement
thread pooling .
so please help me in this. so please send me some
information related to thread pooling. where to use ?
how to use? etc.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Calvin Banks     Answered On: Jul 15

all multiuser platform has its own thread  pool implementation. I dont have
any idea that a generic thread pool api exists. But i can explain how to produce
one for your use.

In a traditional way u can implement  one worker thread per client. client
spesific
information and business logic is implemented together. But if u have a lot of
clients,
this time u have to implement a worker thread pool and a client request queue.
and
also an object for client state. Because you have restricted resources like
memory and
cpu time. (the most importend one is mem). Ýf u prefer traditional way u need
more
memory then expected. For example tomcat has worker threads for client requests,
and a authentication and session manager for client state. And a request queue
for client
requests. Tomcat main thread fetches a request from queue and assing this to a
free
worker thread. Worker thread will use request object to obtain client spesific
information
and creates an response object in order to reflect processed result to client
connection
object.

So what will we do;
- implement a client connection  object to store client conneciton
- implement a main istener thread to receive incoming client connections.
- implement a session manager to store client state informaiton
- implement a worker thread object that accepts client state and input
parameters
to process an action and sets new client state.
- implement a pool (collection) of worker threads (number of threads is up to
u)
- implement a request queue that accepts requests from client connections and
assings one of the free worker threads for process requests.

in the and this will be a multiuser soket server
or this will be a J2EE modeled e-application
or this will be a basic MVC1 struts web application.

So these are common implementations used by many suppliers,developers etc.
but i dont mean to prefer them, u can also create one for your self.

 
Didn't find what you were looking for? Find more on Connection pooling Vs Thread Pooling Or get search suggestion and latest updates.




Tagged: