Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Cory Nelson   on Jul 15 In Java Category.

  
Question Answered By: Calvin Banks   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.

Share: 

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


Tagged: