In a request, it means that when an HTTP request is made, a stream is created or retrieved from the pool to serve it. One thread serves the entire request. The thread per connection will be the same, except that the thread is used for the entire connection, which may be multiple requests and may also have a lot of dead time between requests. Servlet containers are threads for each request. There may be some implementations that offer a thread for each connection, but I don't know, and it seems like it would be very wasteful.
Creating a thread inside another thread does not establish any special relationship, and in most cases this is done if one thread is working more or is completed while the other thread continues to work. In your scenario, using another thread to do the work required by the request will, as you expect, allow you to immediately send a response. The thread used to service this request will also be immediately available for another request, no matter how long your other thread takes. This is pretty much a way of doing asynchronous work in a stream servlet container per request.
Caution: If you are in a full Java EE container, threads can be managed for you in such a way as to create a bad idea, to create your own. In this case, you better ask the container for the stream, but the general principles are the same.
Ryan Stewart Sep 17 '11 at 19:28 2011-09-17 19:28
source share