Here's the thing. Let's say I have a servlet that aacepts some query from the user and runs it against the database, and if I wanted to allow multiple queries to run simultaneously, I don't need to explicitly spawn a new thread right? When a request is sent to the app server, it will automatically spawn a new thread correct? So all I need to be sure of is that the data consistency issues etc. and synchronization is properly handled in my code. Am I correct in assuming this?
1. Each request gets its own Thread - typically a pool of Threads is managed by the servlet container. 2. Servlets must be designed around the request/response cycle. Client applications - typically browsers with humans looking at them - have an expectation that they will get a response within a certain amount of time. 3. IF your queries can execute within the expected time you don't need to do anything special. The request Thread can handle it. 4. IF your request sets off a process that will take a long time (relative to what the client expects) you WILL have to do something special that may or may not involve spawning a new Thread that works while the original request Thread sends some reassuring message back to the user. 5. This sort of thing gets discussed a LOT around here so browse around in the historical forum threads. Bill
subject: Will you ever really need to spawn separate thread if you are writing servlets?