Re: Servlet Threads Question
First off, do some searches on threads and servlets. Depending upon where you get the information, threads in this context can be discouraged or not (see Constant Servlet Running for a good discussion on the subject). A brief overview of the servlet spec doesn't seem to mention anything beyond making sure things are thread safe. That out of the way I'd suggest looking into creating a single thread pool which manages the requests as a queue, so you don't have the overhead of creating so many different threads, have a single manager that manages one or more threads in a queue. Store this as a Session variable, so you can retrieve it from HTTPServletRequest, and pass a reference of the Session to the manager, which will allow you to store the count as a session variable (always access the the Session from your threads in a synchronized way). Finally, create a test structure and hammer at it to be sure doing all of the above results in correct behavior.