Skip to content

Instantly share code, notes, and snippets.

@yanhua365
Created July 14, 2014 08:39
Show Gist options
  • Save yanhua365/c3e93774ae7a37425bca to your computer and use it in GitHub Desktop.
Save yanhua365/c3e93774ae7a37425bca to your computer and use it in GitHub Desktop.
解释Servlet3.0中的异步功能的处理过程
Once your doGet method ends, the response is complete and sent back to the client. Your thread may or may not still be running, but it can't change the response any longer.
What the new async feature in Servlet 3.0 does, is that it allows you to free the request thread for processing another request. What happens is the following:
RequestThread: |-- doGet() { startAsync() } // Thread free to do something else
WorkerThread: |-- do heavy processing --|
OtherThread: |-- send response --|
The important thing is that once RequestThread has started asynchronous processing via a call to startAsync(...), it is free to do something else. It can accept new requests, for example. This improves throughput.
@yanhua365
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment